| |
| |
| |
|
|
| events { |
| worker_connections 2048 |
| use epoll |
| multi_accept on |
| } |
|
|
| http { |
| |
| upstream backend { |
| least_conn |
| |
| |
| |
| server backend:3000 max_fails=3 fail_timeout=30s weight=1 |
| |
| |
| keepalive 32 |
| keepalive_requests 100 |
| keepalive_timeout 60s |
| } |
|
|
| |
| include /etc/nginx/mime.types |
| default_type application/octet-stream |
|
|
| |
| log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
| '$status $body_bytes_sent "$http_referer" ' |
| '"$http_user_agent" "$http_x_forwarded_for" ' |
| 'upstream: $upstream_addr upstream_status: $upstream_status ' |
| 'request_time: $request_time upstream_response_time: $upstream_response_time' |
|
|
| access_log /var/log/nginx/access.log main |
| error_log /var/log/nginx/error.log warn |
|
|
| |
| sendfile on |
| tcp_nopush on |
| tcp_nodelay on |
| server_tokens off |
|
|
| |
| client_body_timeout 12s |
| client_header_timeout 12s |
| send_timeout 10s |
|
|
| |
| client_body_buffer_size 10K |
| client_header_buffer_size 1k |
| client_max_body_size 50m |
| large_client_header_buffers 4 16k |
|
|
| |
| gzip on |
| gzip_vary on |
| gzip_proxied any |
| gzip_comp_level 6 |
| gzip_types text/plain text/css text/xml text/javascript |
| application/json application/javascript application/xml+rss |
| application/rss+xml font/truetype font/opentype |
| application/vnd.ms-fontobject image/svg+xml |
|
|
| |
| server { |
| listen 80 |
| server_name _ |
|
|
| |
| location = /api/v1/health { |
| access_log off |
| proxy_pass http://backend |
| proxy_http_version 1.1 |
| proxy_set_header Connection "" |
| } |
|
|
| location = /api/v1/ready { |
| access_log off |
| proxy_pass http://backend |
| proxy_http_version 1.1 |
| proxy_set_header Connection "" |
| } |
|
|
| |
| location /api/ { |
| |
| proxy_pass http://backend |
| proxy_http_version 1.1 |
| |
| |
| 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_set_header X-Forwarded-Host $host |
| proxy_set_header X-Forwarded-Port $server_port |
| |
| |
| proxy_connect_timeout 60s |
| proxy_send_timeout 60s |
| proxy_read_timeout 60s |
| |
| |
| proxy_buffering on |
| proxy_buffer_size 4k |
| proxy_buffers 8 4k |
| proxy_busy_buffers_size 8k |
| |
| |
| proxy_next_upstream error timeout http_502 http_503 http_504 |
| proxy_next_upstream_tries 2 |
| |
| |
| proxy_cache_bypass $http_upgrade |
| add_header X-Cache-Status $upstream_cache_status |
| } |
|
|
| |
| location / { |
| return 200 '{"message":"API Server Running","status":"ok"}' |
| add_header Content-Type application/json |
| } |
|
|
| |
| error_page 502 503 504 /50x.html |
| location = /50x.html { |
| return 503 '{"error":"Service temporarily unavailable","status":503}' |
| add_header Content-Type application/json |
| } |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |