Skip to content

Commit

Permalink
Merge pull request #35 from neogenia-jp/feature/update-nginx-config-f…
Browse files Browse the repository at this point in the history
…or-websocket-implicitly

WebSocket の疎通を暗黙的にするように設定した
  • Loading branch information
lobin-z0x50 authored Jun 26, 2024
2 parents e3f2ae0 + 599b5dc commit 61dedf7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/app/config_template_http.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ map $http_x_forwarded_proto $xfp {
"" $scheme;
}

map $http_connection $conn {
default keep-alive; # for HTTP keepalive
upgrade upgrade; # for WebSocket
}

# --- server definitions for plain HTTP ---
server {
server_name <%= config.domain %>;
Expand Down Expand Up @@ -50,7 +55,9 @@ server {
grpc_pass $target_upstream;
<% else %>
proxy_http_version 1.1;
proxy_set_header Connection ""; # for HTTP keepalive
# for WebSocket
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $conn;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $xfp;
Expand Down
9 changes: 8 additions & 1 deletion src/app/config_template_https.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ map $http_x_forwarded_proto $xfp {
"" $scheme;
}

map $http_connection $conn {
default keep-alive; # for HTTP keepalive
upgrade upgrade; # for WebSocket
}

# --- server definitions for plain HTTP ---
server {
server_name <%= config.domain %>;
Expand Down Expand Up @@ -71,7 +76,9 @@ server {
grpc_pass $target_upstream;
<% else %>
proxy_http_version 1.1;
proxy_set_header Connection ""; # for HTTP keepalive
# for WebSocket
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $conn;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $xfp;
Expand Down

0 comments on commit 61dedf7

Please sign in to comment.