-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.com.nginx.conf
More file actions
49 lines (41 loc) · 1.93 KB
/
Copy pathexample.com.nginx.conf
File metadata and controls
49 lines (41 loc) · 1.93 KB
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
# Redirects http to https
# This handler only handles http on port 80, and redirects the request to use https
server {
server_name example.com www.example.com;
listen 80 ;
return 301 https://$host$request_uri;
}
# Redirects non-www to www
# This handler only handles https on port 443, for the non-www domain, and redirects to the www domain.
server {
server_name example.com;
listen 443 ssl http2 ;
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.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
return 301 $scheme://www.example.com$request_uri;
}
# This handler handles https for the www domain, and is the main handler.
server {
server_name www.example.com;
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.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
client_max_body_size 150M;
location /widgets/images/ {
root /var/www/www.example.com;
expires 1w;
}
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host www.example.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}