raazkumar commited on
Commit
19eb9d3
·
verified ·
1 Parent(s): a845c8d

Upload production/nginx.conf

Browse files
Files changed (1) hide show
  1. production/nginx.conf +118 -0
production/nginx.conf ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ user nginx;
2
+ worker_processes auto;
3
+ error_log /var/log/nginx/error.log warn;
4
+ pid /var/run/nginx.pid;
5
+
6
+ events {
7
+ worker_connections 4096;
8
+ use epoll;
9
+ multi_accept on;
10
+ }
11
+
12
+ http {
13
+ include /etc/nginx/mime.types;
14
+ default_type application/octet-stream;
15
+
16
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
17
+ '$status $body_bytes_sent "$http_referer" '
18
+ '"$http_user_agent" "$http_x_forwarded_for" '
19
+ 'rt=$request_time uct="$upstream_connect_time" '
20
+ 'uht="$upstream_header_time" urt="$upstream_response_time" '
21
+ 'correlation_id=$http_x_correlation_id';
22
+
23
+ access_log /var/log/nginx/access.log main;
24
+ sendfile on;
25
+ tcp_nopush on;
26
+ tcp_nodelay on;
27
+ keepalive_timeout 65;
28
+ keepalive_requests 1000;
29
+ types_hash_max_size 2048;
30
+
31
+ gzip on;
32
+ gzip_vary on;
33
+ gzip_min_length 1024;
34
+ gzip_proxied expired no-cache no-store private auth;
35
+ gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
36
+
37
+ limit_req_zone $binary_remote_addr zone=api_limit:10m rate=100r/s;
38
+ limit_req_zone $binary_remote_addr zone=health_limit:10m rate=10r/s;
39
+ limit_conn_zone $binary_remote_addr zone=addr_limit:10m;
40
+
41
+ upstream api_backend {
42
+ least_conn;
43
+ server api:8000 max_fails=3 fail_timeout=30s;
44
+ keepalive 32;
45
+ }
46
+
47
+ ssl_protocols TLSv1.2 TLSv1.3;
48
+ ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
49
+ ssl_prefer_server_ciphers off;
50
+ ssl_session_cache shared:SSL:10m;
51
+ ssl_session_timeout 10m;
52
+
53
+ server {
54
+ listen 80;
55
+ server_name _;
56
+
57
+ location /health {
58
+ limit_req zone=health_limit burst=20 nodelay;
59
+ proxy_pass http://api_backend;
60
+ proxy_http_version 1.1;
61
+ proxy_set_header Connection "";
62
+ proxy_set_header Host $host;
63
+ proxy_set_header X-Real-IP $remote_addr;
64
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
65
+ proxy_set_header X-Forwarded-Proto $scheme;
66
+ proxy_connect_timeout 5s;
67
+ proxy_send_timeout 60s;
68
+ proxy_read_timeout 60s;
69
+ }
70
+
71
+ location /metrics {
72
+ allow 10.0.0.0/8;
73
+ allow 172.16.0.0/12;
74
+ allow 192.168.0.0/16;
75
+ deny all;
76
+ proxy_pass http://api_backend;
77
+ proxy_http_version 1.1;
78
+ proxy_set_header Host $host;
79
+ }
80
+
81
+ location / {
82
+ limit_req zone=api_limit burst=200 nodelay;
83
+ limit_conn addr_limit 50;
84
+ proxy_pass http://api_backend;
85
+ proxy_http_version 1.1;
86
+ proxy_set_header Connection "";
87
+ proxy_set_header Host $host;
88
+ proxy_set_header X-Real-IP $remote_addr;
89
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
90
+ proxy_set_header X-Forwarded-Proto $scheme;
91
+ proxy_set_header X-Correlation-ID $http_x_correlation_id;
92
+ proxy_connect_timeout 10s;
93
+ proxy_send_timeout 300s;
94
+ proxy_read_timeout 300s;
95
+ proxy_buffering off;
96
+ proxy_cache off;
97
+ proxy_redirect off;
98
+ proxy_intercept_errors on;
99
+ error_page 502 503 504 /maintenance.html;
100
+ }
101
+
102
+ location /maintenance.html {
103
+ root /usr/share/nginx/html;
104
+ internal;
105
+ }
106
+
107
+ location /ws {
108
+ proxy_pass http://api_backend;
109
+ proxy_http_version 1.1;
110
+ proxy_set_header Upgrade $http_upgrade;
111
+ proxy_set_header Connection "upgrade";
112
+ proxy_set_header Host $host;
113
+ proxy_set_header X-Real-IP $remote_addr;
114
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
115
+ proxy_read_timeout 86400;
116
+ }
117
+ }
118
+ }