|
worker_processes auto; |
|
worker_rlimit_nofile 65535; |
|
|
|
events { |
|
use epoll; |
|
worker_connections 65535; |
|
multi_accept on; |
|
} |
|
|
|
http { |
|
|
|
sendfile on; |
|
tcp_nodelay on; |
|
tcp_nopush on; |
|
proxy_buffering off; |
|
chunked_transfer_encoding on; |
|
|
|
|
|
include /etc/nginx/mime.types; |
|
|
|
|
|
client_max_body_size 100M; |
|
client_body_buffer_size 128k; |
|
client_body_timeout 30s; |
|
client_header_timeout 30s; |
|
|
|
|
|
keepalive_timeout 120; |
|
keepalive_requests 100; |
|
|
|
|
|
gzip on; |
|
gzip_vary on; |
|
gzip_proxied any; |
|
gzip_comp_level 6; |
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; |
|
|
|
|
|
proxy_request_buffering off; |
|
|
|
|
|
access_log /tmp/nginx_access.log; |
|
error_log /tmp/nginx_error.log warn; |
|
|
|
|
|
upstream backend { |
|
least_conn; |
|
server 127.0.0.1:3000 max_fails=3 fail_timeout=30s; |
|
keepalive 64; |
|
} |
|
|
|
server { |
|
listen 3001 http2; |
|
|
|
server_name localhost; |
|
|
|
|
|
location /ai/v1/ { |
|
rewrite ^/ai/v1/(.*)$ /v1/$1 break; |
|
proxy_pass http://backend; |
|
|
|
|
|
proxy_set_header Host $host; |
|
proxy_set_header Upgrade $http_upgrade; |
|
proxy_set_header Connection "upgrade"; |
|
|
|
|
|
proxy_set_header X-Forwarded-For ""; |
|
proxy_set_header X-Real-IP ""; |
|
proxy_set_header X-Direct-Url ""; |
|
proxy_set_header X-Forwarded-Port ""; |
|
proxy_set_header X-Ip-Token ""; |
|
proxy_set_header X-Request-Id ""; |
|
proxy_set_header X-Amzn-Trace-Id ""; |
|
proxy_set_header X-Forwarded-Proto ""; |
|
|
|
|
|
proxy_connect_timeout 60s; |
|
proxy_send_timeout 60s; |
|
proxy_read_timeout 60s; |
|
|
|
error_page 503 =429 /429.html; |
|
} |
|
|
|
location / { |
|
proxy_pass http://backend; |
|
|
|
|
|
proxy_set_header Host $host; |
|
proxy_set_header Upgrade $http_upgrade; |
|
proxy_set_header Connection "upgrade"; |
|
|
|
|
|
proxy_set_header X-Forwarded-For ""; |
|
proxy_set_header X-Real-IP ""; |
|
proxy_set_header X-Direct-Url ""; |
|
proxy_set_header X-Forwarded-Port ""; |
|
proxy_set_header X-Ip-Token ""; |
|
proxy_set_header X-Request-Id ""; |
|
proxy_set_header X-Amzn-Trace-Id ""; |
|
proxy_set_header X-Forwarded-Proto ""; |
|
|
|
|
|
proxy_connect_timeout 60s; |
|
proxy_send_timeout 60s; |
|
proxy_read_timeout 60s; |
|
|
|
error_page 503 =429 /429.html; |
|
} |
|
|
|
|
|
location = /429.html { |
|
return 429 'Too Many Requests'; |
|
} |
|
} |
|
} |
|
|