-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodejs.conf
73 lines (60 loc) · 2.25 KB
/
nodejs.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
upstream exampleapi {
server 127.0.0.1:5000; # Node application port
keepalive 64;
}
server {
server_name api.example.com;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload";
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
location / {
# Allow access to API only from certain domains
# valid_referers server_names app.example.com;
# valid_referers server_names anotherapp.example.com;
# if ($invalid_referer) {
# set $valid N;
# }
# Whitelist Webhooks For Eg: Razorpay
# if ($http_user_agent ~ (Razorpay-Webhook/v1) ) {
# set $valid Y;
# }
# Show 403 Page to Restricted things
# if ($valid = N) {
# return 403;
# }
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://exampleapi/;
proxy_redirect off;
proxy_read_timeout 240s;
client_max_body_size 100M;
}
# Custom 403 HTML Page
error_page 403 /403.html;
location = /403.html {
root /usr/share/nginx/html;
internal;
}
# Appended & Managed by Certbot Script (Optional)
# Remove if you want to serve on HTTP
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
# Appended & Managed by Certbot Script (Optional)
# Remove if you want to serve on HTTP
# Ref: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04
server {
if ($host = api.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name api.example.com;
listen 80;
return 404; # managed by Certbot
}