forked from Rav4s/NginX-Config-Files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverse-proxy.conf
86 lines (62 loc) · 2.64 KB
/
reverse-proxy.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
74
75
76
77
78
79
80
81
82
83
84
85
86
# Example configuration for a www-subdomain
# Redirect www http traffic to www https
server{
listen 80;
server_name www.YOURSITEDOMAIN.com;
return 301 https://www.YOURSITEDOMAIN.com$request_uri;
}
# Redirect non-www http traffic to www https
server {
listen 80;
server_name YOURSITEDOMAIN.com;
return 301 https://www.YOURSITEDOMAIN.com$request_uri;
}
# Redirect non-www https traffic to www https
server {
listen 443;
server_name YOURSITEDOMAIN.com;
return 301 https://www.YOURSITEDOMAIN.com$request_uri;
# SSL configuration
ssl_certificate /etc/letsencrypt/live/YOURSITEDOMAIN.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/YOURSITEDOMAIN.com/privkey.pem;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
}
# Main server block for www https
server {
listen 443;
server_name www.YOURSITEDOMAIN.com;
# SSL configuration
ssl_certificate /etc/letsencrypt/live/YOURSITEDOMAIN.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/YOURSITEDOMAIN.com/privkey.pem;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
# Set the access log location
access_log /var/log/nginx/YOURSITEDOMAIN.access.log;
location / {
# Set the proxy headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Configure which address the request is proxied to
proxy_pass http://YOURSERVER:YOURPORT;
proxy_read_timeout 90;
proxy_redirect http://YOURSERVER:YOURPORT https://www.YOURSITEDOMAIN.com;
# Set the security headers
add_header Permissions-Policy "interest-cohort=()"; # Don't allow Google FLoC
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"; #HSTS
add_header X-Frame-Options DENY; #Prevents clickjacking
add_header X-Content-Type-Options nosniff; #Prevents mime sniffing
add_header X-XSS-Protection "1; mode=block"; #Prevents cross-site scripting attacks
add_header Referrer-Policy "origin"; #Idk what this actually does
# Rewrite all URI's so they have a trailing slash
rewrite ^([^.]*[^/])$ $1/ permanent;
}
}