-
Notifications
You must be signed in to change notification settings - Fork 1
/
nginx.conf
346 lines (254 loc) · 9.67 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
worker_processes 5;
events {
worker_connections 4096;
# worker processes will accept new connections by turn.
# Otherwise, all worker processes will be notified about new connections,
# and if volume of new connections is low, some of the worker processes may just waste system resources.
accept_mutex on;
}
http {
# Avoid disclosing information about nginx
server_tokens off;
# Sets the maximum allowed size of the client request body.
client_max_body_size 50m;
# Sets buffer size for reading client request body.
# In case the request body is larger than the buffer,
# the whole body or only its part is written to a temporary file.
client_body_buffer_size 128k;
# Defines files that will be used as an index.
index index.html index.htm;
# MIME types
# List to identifying files on the Internet
# according to their nature and format.
include mime.types;
default_type application/octet-stream;
# logging
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# sets a timeout during which a keep-alive
# client connection will stay open on the server side.
keepalive_timeout 75;
# GZIP
gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_vary on;
gzip_comp_level 6;
gzip_types text/plain text/css application/javascript;
map $request_method $access_control_max_age {
OPTIONS 1728000; # 20 days
}
upstream app {
# References to our app containers, via docker compose
server flask_app:5000;
}
upstream pgadmin4 {
# References to our app containers, via docker compose
server pgadmin4:80;
}
upstream flower {
server flower_container:5555;
}
# SSL
# Specifies a time during which a
# client may reuse the session parameters.
ssl_session_timeout 1d;
# Sets the types and sizes of caches that
# store session parameters
# a cache shared between all worker processes
ssl_session_cache shared:SSL:10m;
# Enables or disables session resumption
# through TLS session tickets.
ssl_session_tickets off;
ssl_ecdh_curve secp384r1:X25519:prime256v1;
ssl_buffer_size 8k;
# OCSP Stapling
ssl_stapling on;
ssl_stapling_verify on;
# Diffie-Hellman parameter for DHE ciphersuites
ssl_dhparam /etc/nginx/certs/dhparam.pem;
# SSL Ciphers
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_protocols TLSv1.2 TLSv1.3;
# server {
# listen 80;
# server_name _;
# location ^~ /.well-known {
# allow all;
# root /data/letsencrypt/;
# }
# location / {
# return 301 https://chewbbaca.online$request_uri;
# }
# }
server {
listen 443 ssl http2;
server_name {{cookiecutter.server_name}};
# SSL self-signed certificates
ssl_certificate /etc/nginx/certs/cert.pem;
ssl_certificate_key /etc/nginx/certs/key.pem;
# # Letsencrypt certficates
# ssl_certificate /etc/letsencrypt/live/chewbbaca.online/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/chewbbaca.online/privkey.pem;
# Security headers
include general-security-headers.conf;
# Path to the static files
root /var/www/my-app;
location / {
# Checks the existence of files in the specified
# order and uses the first found file for request processing.
try_files $uri $uri/ /index.html;
# General security headers.
include general-security-headers.conf;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
# ACME challenge location
# location ^~ /.well-known {
# allow all;
# root /data/letsencrypt/;
# }
# Media: images, icons, video, audio, HTC
# location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
# expires 1M;
# access_log off;
# include general-security-headers.conf;
# add_header Cache-Control "no-cache, no-store, must-revalidate";
# }
# Javascript and CSS files
# location ~* \.(?:css|js)$ {
# try_files $uri =404;
# expires 1y;
# access_log off;
# include general-security-headers.conf;
# add_header Cache-Control "no-cache, no-store, must-revalidate";
# }
location /NS/api/swagger.json {
proxy_pass http://app/NS/api/swagger.json;
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-Host $server_name;
include general-security-headers.conf;
# include cors.conf;
}
location /NS/api/ {
proxy_pass http://app/NS/api/;
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-Host $server_name;
include general-security-headers.conf;
# include cors.conf;
}
location ^~ /swaggerui/ {
proxy_pass http://app/swaggerui/;
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-Host $server_name;
include general-security-headers.conf;
# include cors.conf;
}
location ^~ /api/ {
proxy_pass http://app/;
proxy_redirect off;
proxy_http_version 1.1;
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;
}
location ^~ /pgadmin {
# auth_basic "Database Administrator's Area";
# auth_basic_user_file /etc/nginx/.htpasswd;
root /var/www;
proxy_set_header X-Script-Name /pgadmin;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
include general-security-headers.conf;
proxy_pass http://pgadmin4/;
proxy_redirect off;
}
location ^~ /flower {
# auth_basic "Queue Administrator's Area";
# auth_basic_user_file /etc/nginx/.htpasswd;
root /var/www;
rewrite ^/flower/?(.*)$ /$1 break;
proxy_pass http://flower/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
include general-security-headers.conf;
}
# Proxy download compressed files
location ~* ^/compressed_schemas/(.*?)/(.*) {
# Do not allow people to mess with this location directly
# Only internal redirects are allowed
internal;
# Location-specific logging
#access_log logs/internal_redirect.access.log main;
#error_log logs/internal_redirect.error.log warn;
# How to resolve remote URLs.
# It’s inside a Docker container with dnsmasq running
# so 127.0.0.1 is used
resolver 127.0.0.1 ipv6=off;
# Extract download url from the request
set $download_uri $2;
set $download_host $1;
# Compose download url
set $download_url http://$download_host/$download_uri;
# Set download request headers
proxy_set_header Host $download_host;
proxy_set_header Authorization '';
# The next two lines could be used if your storage
# backend does not support Content-Disposition
# headers used to specify file name browsers use
# when save content to the disk
proxy_hide_header Content-Disposition;
include general-security-headers.conf;
add_header Content-Disposition 'attachment; filename="$args"';
# Do not touch local disks when proxying
# content to clients
proxy_max_temp_file_size 0;
# Download the file and send it to client
proxy_pass $download_url;
}
# Proxy download prodigal training files
location ~* ^/prodigal_training_files/(.*?)/(.*) {
internal;
resolver 127.0.0.1 ipv6=off;
set $download_uri $2;
set $download_host $1;
set $download_url http://$download_host/$download_uri;
proxy_set_header Host $download_host;
proxy_set_header Authorization '';
proxy_hide_header Content-Disposition;
include general-security-headers.conf;
add_header Content-Disposition 'attachment; filename="$args"';
proxy_max_temp_file_size 0;
proxy_pass $download_url;
}
}
# Redirect IP to Server Name
# server {
# listen 443 ssl http2;
# # SSL certificates
# #ssl_certificate /etc/nginx/certs/cert.pem;
# #ssl_certificate_key /etc/nginx/certs/key.pem;
# # Letsencrypt certficates
# ssl_certificate /etc/letsencrypt/live/chewbbaca.online/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/chewbbaca.online/privkey.pem;
# server_name _;
# return 301 $scheme://chewbbaca.online$request_uri;
# }
# proxy_read_timeout 300s;
# proxy_send_timeout 300s;
}