forked from readium/playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
84 lines (70 loc) · 2.8 KB
/
nginx.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
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name readium.balashan.dev;
location / {
try_files $uri $uri/ =404;
}
}
server {
server_name readium.balashan.dev www.readium.balashan.dev;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
proxy_cache_bypass $http_upgrade;
gzip on;
gzip_comp_level 4;
gzip_types text/plain application/xml application/json application/javascript;
# Important for Next.js routing
try_files $uri $uri/ /_next/static/index.html;
# Logs for frontend
error_log /var/log/nginx/readium-web_error.log;
access_log /var/log/nginx/readium-web_access.log;
}
location ^~ /_next/static/ {
root /home/ubuntu/projects/myapp/frontend/readium/playground/.next;
proxy_pass http://localhost:3000;
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable";
}
location / {
proxy_pass http://localhost:15080; # Go app's port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
try_files $uri $uri/ =404;
# Logs for backend - go app
error_log /var/log/nginx/go-toolkit_error.log;
access_log /var/log/nginx/go-toolkit_access.log;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/readium.balashan.dev/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/readium.balashan.dev/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
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline' 'unsafe-eval'" always;
# Maximum upload size
client_max_body_size 100M;
# Buffer size settings
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
}
server {
if ($host = readium.balashan.dev) {
return 301 https://$host$request_uri;
}
}