connection upgrade with nginx
This commit is contained in:
@@ -54,6 +54,7 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./requirements/nginx/conf/default.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./requirements/nginx/conf/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
- ./requirements/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
command: [nginx-debug, "-g", "daemon off;"]
|
command: [nginx-debug, "-g", "daemon off;"]
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
server {
|
server {
|
||||||
listen 8080 default_server;
|
listen 8080 default_server;
|
||||||
listen 8042;
|
|
||||||
listen [::]:8080 default_server;
|
listen [::]:8080 default_server;
|
||||||
server_name transcendance;
|
server_name transcendance;
|
||||||
|
|
||||||
@@ -11,6 +10,15 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
proxy_pass http://backend_dev:3000;
|
proxy_pass http://backend_dev:3000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /pong {
|
||||||
|
proxy_pass http://game_server:8042/pong;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
@@ -18,13 +26,6 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
proxy_pass http://frontend_dev:8080;
|
proxy_pass http://frontend_dev:8080;
|
||||||
}
|
}
|
||||||
location /pong {
|
|
||||||
http://game_server:8042/pong;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection $connection_upgrade;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
|||||||
37
srcs/requirements/nginx/conf/nginx.conf
Normal file
37
srcs/requirements/nginx/conf/nginx.conf
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
user nginx;
|
||||||
|
worker_processes auto;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log notice;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
http {
|
||||||
|
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"';
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
#tcp_nopush on;
|
||||||
|
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
#gzip on;
|
||||||
|
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
}
|
||||||
@@ -25,8 +25,7 @@ class ClientInfoSpectator {
|
|||||||
playerRightNextPos: VectorInteger;
|
playerRightNextPos: VectorInteger;
|
||||||
}
|
}
|
||||||
|
|
||||||
const wsPort = 8042;
|
const wsUrl = "ws://transcendance:8080/pong";
|
||||||
const wsUrl = "ws://transcendance:" + wsPort + "/pong";
|
|
||||||
export let socket: WebSocket; /* TODO: A way to still use "const" not "let" ? */
|
export let socket: WebSocket; /* TODO: A way to still use "const" not "let" ? */
|
||||||
export const clientInfo = new ClientInfo();
|
export const clientInfo = new ClientInfo();
|
||||||
export const clientInfoSpectator = new ClientInfoSpectator(); // WIP, could refactor this
|
export const clientInfoSpectator = new ClientInfoSpectator(); // WIP, could refactor this
|
||||||
|
|||||||
Reference in New Issue
Block a user