This repository was archived by the owner on Aug 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample app.conf
104 lines (85 loc) · 2.63 KB
/
sample app.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/frontend.log;
# Disable nginx version in headers
server_tokens off;
# Remove trailing slash
rewrite ^/(.*)/$ /$1 permanent;
location / {
try_files $uri $uri/ @frontend;
}
location /media/ {
# Disable directory index listing
autoindex off;
alias /media_files/;
}
location /sitemap.xml {
add_header Content-Type text/xml;
try_files $uri $uri/ @backend;
}
location /robots.txt {
add_header Content-Type text/plain;
return 200 "User-agent: *\nAllow: /\nSitemap: https://example.com/sitemap.xml\n";
}
# Do not cache service-worker.js, required for offline-first updates.
location /service-worker.js {
alias /next/service-worker.js;
add_header Cache-Control "no-cache";
proxy_cache_bypass $http_pragma;
proxy_cache_revalidate on;
expires off;
access_log off;
}
location @frontend {
proxy_pass http://frontend:3000;
proxy_pass_request_headers on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
location @backend {
proxy_pass http://backend:8000;
proxy_pass_request_headers on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}
server {
listen 80;
server_name api.example.com admin.example.com;
location = /favicon.ico { access_log off; log_not_found off; }
access_log /var/log/nginx/backend.log;
# Set upload limit (for media files)
client_max_body_size 100M;
# Disable nginx version in headers
server_tokens off;
location = /robots.txt {
add_header Content-Type text/plain;
return 200 "User-agent: *\nDisallow: /\n";
}
location /static/ {
# Disable directory index listing
autoindex off;
alias /static_files/;
}
location /media/ {
# Disable directory index listing
autoindex off;
alias /media_files/;
}
location / {
try_files $uri $uri/ @backend;
}
location @backend {
proxy_pass http://backend:8000;
proxy_pass_request_headers on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
}