-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
83 lines (65 loc) · 2.28 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
# nginx.conf
# load_module modules/nginx_cookie_flag_module;
events {
worker_connections 1024;
}
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=STATIC:10m inactive=7d use_temp_path=off;
upstream nextjs {
server nextjs:8080;
keepalive 8;
}
server {
listen 80;
listen [::]:80;
server_name localhost demac-eg.co www.demac-eg.co;
server_tokens off;
location /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/certbot;
break;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 default_server ssl http2;
listen [::]:443 ssl http2;
server_name localhost demac-eg.co www.demac-eg.co;
root /srv/public;
ssl_certificate /etc/nginx/ssl/live/demac-eg.co/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/demac-eg.co/privkey.pem;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
server_tokens off;
gzip on;
gzip_proxied any;
gzip_comp_level 4;
gzip_types text/plain text/css text/javascript image/svg+xml image/x-icon application/javascript application/x-javascript application/json;
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;
# BUILT ASSETS (E.G. JS BUNDLES)
# Browser cache - max cache headers from Next.js as build id in url
# Server cache - valid forever (cleared after cache "inactive" period)
location /_next/static {
proxy_cache STATIC;
proxy_pass http://nextjs;
}
# STATIC ASSETS (E.G. IMAGES)
# Browser cache - "no-cache" headers from Next.js as no build id in url
# Server cache - refresh regularly in case of changes
location /static {
proxy_cache STATIC;
proxy_ignore_headers Cache-Control;
proxy_cache_valid 60m;
proxy_pass http://nextjs;
}
# DYNAMIC ASSETS - NO CACHE
location / {
proxy_pass http://nextjs;
}
}
}