Last active
February 23, 2024 19:15
-
-
Save malikdoksoz/501597a6faca5ef073c8df966f920d93 to your computer and use it in GitHub Desktop.
nginx websocket adonisjs 5 reverse proxy
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
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
upstream adoniswebsocket { | |
# IP:Port | |
server 127.0.0.1:3333 weight=5 max_fails=3 fail_timeout=30s; | |
keepalive 16; | |
} | |
server { | |
listen 80; | |
listen 443 ssl; | |
server_name yourdomain.com; | |
ssl_certificate /etc/nginx/ssl/cert.pem; | |
ssl_certificate_key /etc/nginx/ssl/key.pem; | |
ssl_session_timeout 5m; | |
ssl_session_cache shared:SSL:10m; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3 SSLv2 SSLv3; | |
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; | |
ssl_prefer_server_ciphers on; | |
ssl_verify_client off; | |
client_max_body_size 10M; | |
root /var/www/html/adonisjs; | |
# access_log /docker/log/nginx/$server_name.access.log main; | |
autoindex off; | |
index index.html index.htm; | |
location / { | |
try_files $uri @adoniswebs; | |
} | |
location @adoniswebs { | |
proxy_http_version 1.1; | |
# proxy_connect_timeout 60s; | |
# proxy_send_timeout 60s; | |
# proxy_read_timeout 120s; | |
proxy_redirect off; | |
proxy_set_header Connection ""; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Real-PORT $remote_port; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header Scheme $scheme; | |
proxy_set_header Server-Protocol $server_protocol; | |
proxy_set_header Server-Name $server_name; | |
proxy_set_header Server-Addr $server_addr; | |
proxy_set_header Server-Port $server_port; | |
proxy_pass http://adoniswebsocket; | |
} | |
} | |
server { | |
listen 8443 ssl; | |
server_name yourdomain.com; | |
ssl_certificate /etc/nginx/ssl/cert.pem; | |
ssl_certificate_key /etc/nginx/ssl/key.pem; | |
ssl_session_timeout 5m; | |
ssl_session_cache shared:SSL:10m; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3; | |
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; | |
ssl_prefer_server_ciphers on; | |
ssl_verify_client off; | |
root /var/www/html/adonisjs; | |
autoindex off; | |
index index.html index.htm; | |
location =/ws { | |
proxy_http_version 1.1; | |
proxy_redirect off; | |
proxy_connect_timeout 60s; | |
proxy_send_timeout 15s; | |
proxy_read_timeout 15s; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Real-PORT $remote_port; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header Scheme $scheme; | |
proxy_set_header Server-Protocol $server_protocol; | |
proxy_set_header Server-Name $server_name; | |
proxy_set_header Server-Addr $server_addr; | |
proxy_set_header Server-Port $server_port; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
proxy_pass http://adoniswebsocket; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment