-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proxies timeouts and DNS resolving (#166)
- Loading branch information
Showing
8 changed files
with
265 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
map $http_upgrade $conn_upgrade { | ||
default ""; | ||
"websocket" "Upgrade"; | ||
} | ||
|
||
log_format logger-json escape=json | ||
'{' | ||
'"source": "client-proxy",' | ||
'"time": "$time_iso8601",' | ||
'"resp_body_size": $body_bytes_sent,' | ||
'"host": "$http_host",' | ||
'"address": "$remote_addr",' | ||
'"request_length": $request_length,' | ||
'"method": "$request_method",' | ||
'"uri": "$request_uri",' | ||
'"status": $status,' | ||
'"user_agent": "$http_user_agent",' | ||
'"resp_time": $request_time,' | ||
'"upstream_addr": "$upstream_addr"' | ||
'}'; | ||
access_log /var/log/nginx/access.log logger-json; | ||
|
||
server { | ||
listen 3002 default_server; | ||
|
||
server_name _; | ||
return 502 "Cannot connect to sandbox"; | ||
} | ||
[[ range service "session-proxy" ]] | ||
server { | ||
listen 3002; | ||
access_log /var/log/nginx/access.log logger-json; | ||
|
||
server_name ~^(.+)-[[ index .ServiceMeta "Client" | sprig_substr 0 8 ]]\.${domain_name_escaped}$; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
|
||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $conn_upgrade; | ||
|
||
proxy_hide_header x-frame-options; | ||
|
||
proxy_http_version 1.1; | ||
|
||
client_body_timeout 86400s; | ||
client_header_timeout 5s; | ||
|
||
# proxy_read_timeout 600s; | ||
proxy_read_timeout 1d; | ||
proxy_send_timeout 86400s; | ||
|
||
proxy_cache_bypass 1; | ||
proxy_no_cache 1; | ||
|
||
client_max_body_size 1024m; | ||
|
||
proxy_buffering off; | ||
proxy_request_buffering off; | ||
|
||
tcp_nodelay on; | ||
tcp_nopush on; | ||
sendfile on; | ||
# send_timeout 600s; | ||
# proxy_connect_timeout 30s; | ||
|
||
keepalive_timeout 600s; | ||
keepalive_requests 2048; | ||
|
||
# gzip off; | ||
location / { | ||
proxy_pass $scheme://[[ .Address ]]:[[ .Port ]]$request_uri; | ||
} | ||
} | ||
[[ end ]] | ||
server { | ||
listen 3001; | ||
location /health { | ||
access_log off; | ||
add_header 'Content-Type' 'application/json'; | ||
return 200 '{"status":"UP"}'; | ||
} | ||
|
||
location /status { | ||
access_log off; | ||
stub_status; | ||
allow all; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
user nginx; | ||
worker_processes auto; | ||
|
||
error_log /var/log/nginx/error.log notice; | ||
pid /var/run/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
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"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_time 86400s; | ||
|
||
#gzip on; | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
map $host $dbk_port { | ||
default ""; | ||
"~^(?<p>\d+)-" ":$p"; | ||
} | ||
|
||
map $host $dbk_session_id { | ||
default ""; | ||
"~-(?<s>\w+)-" $s; | ||
} | ||
|
||
map $http_upgrade $conn_upgrade { | ||
default ""; | ||
"websocket" "Upgrade"; | ||
} | ||
|
||
log_format logger-json escape=json | ||
'{' | ||
'"source": "session-proxy",' | ||
'"time": "$time_iso8601",' | ||
'"resp_body_size": $body_bytes_sent,' | ||
'"host": "$http_host",' | ||
'"address": "$remote_addr",' | ||
'"request_length": $request_length,' | ||
'"method": "$request_method",' | ||
'"uri": "$request_uri",' | ||
'"status": $status,' | ||
'"user_agent": "$http_user_agent",' | ||
'"resp_time": $request_time,' | ||
'"upstream_addr": "$upstream_addr"' | ||
'}'; | ||
access_log /var/log/nginx/access.log logger-json; | ||
|
||
server { | ||
listen 3003; | ||
|
||
# DNS server resolved addreses as to <sandbox-id> <ip-address> | ||
resolver 127.0.0.1; | ||
resolver_timeout 5s; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
|
||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $conn_upgrade; | ||
|
||
proxy_hide_header x-frame-options; | ||
|
||
proxy_http_version 1.1; | ||
|
||
client_body_timeout 86400s; | ||
client_header_timeout 5s; | ||
|
||
proxy_read_timeout 600s; | ||
proxy_send_timeout 86400s; | ||
|
||
proxy_cache_bypass 1; | ||
proxy_no_cache 1; | ||
|
||
client_max_body_size 1024m; | ||
|
||
proxy_buffering off; | ||
proxy_request_buffering off; | ||
|
||
tcp_nodelay on; | ||
tcp_nopush on; | ||
sendfile on; | ||
|
||
# send_timeout 600s; | ||
|
||
proxy_connect_timeout 3s; | ||
keepalive_requests 2048; | ||
keepalive_timeout 600s; | ||
# gzip off; | ||
|
||
location / { | ||
if ($dbk_session_id = "") { | ||
return 502 "Cannot connect to sandbox"; | ||
} | ||
|
||
proxy_pass $scheme://$dbk_session_id$dbk_port$request_uri; | ||
} | ||
} | ||
|
||
server { | ||
listen 3004; | ||
|
||
location /health { | ||
access_log off; | ||
add_header 'Content-Type' 'application/json'; | ||
return 200 '{"status":"UP"}'; | ||
} | ||
|
||
location /status { | ||
access_log off; | ||
stub_status; | ||
allow all; | ||
} | ||
} |
Oops, something went wrong.