diff --git a/conf.d/proxy-common.conf b/conf.d/proxy-common.conf new file mode 100644 index 0000000..30586a9 --- /dev/null +++ b/conf.d/proxy-common.conf @@ -0,0 +1,27 @@ +# Set headers for proxied requests +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; + +# WebSocket support +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +# Proxy buffering +proxy_http_version 1.1; +proxy_set_header Upgrade $http_upgrade; +proxy_set_header Connection $connection_upgrade; +proxy_buffering off; +proxy_cache_bypass $http_upgrade; + +# Timeouts +proxy_connect_timeout 10s; +proxy_send_timeout 60s; +proxy_read_timeout 3600s; # long-lived websocket connections + +# limits +limit_req zone=req_limit burst=10 nodelay; +limit_conn zone=conn_limit 10;