-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx-vhost.template.conf
45 lines (37 loc) · 1.24 KB
/
nginx-vhost.template.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
#
# HTTPS virtual host proxy configuration template for nginx
#
# #SERVER_NAME# - server name
# #CERT_NAME# - certificate file name without extension
# #SERVICE_PORT# - service port to proxy
#
# Usage (using demo.vrerv.com):
#
# `cp ./nginx-vhost.template.conf ./nginx/conf.d/demo.vrerv.com.conf`
# `perl -pi -e 's/#SERVER_NAME#/demo.vrerv.com/g' ./nginx/conf.d/demo.vrerv.com.conf'`
# `perl -pi -e 's/#CERT_NAME#/vrerv.com/g' ./nginx/conf.d/demo.vrerv.com.conf'`
# `perl -pi -e 's/#SERVICE_PORT#/3000/g' ./nginx/conf.d/demo.vrerv.com.conf'`
#
server {
listen 80;
listen [::]:80;
server_name #SERVER_NAME#;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name #SERVER_NAME#;
ssl_certificate /etc/nginx/ssl/#CERT_NAME#.crt;
ssl_certificate_key /etc/nginx/ssl/#CERT_NAME#.key;
location / {
proxy_pass http://dockerhost:#SERVICE_PORT#;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}