Skip to content

Instantly share code, notes, and snippets.

@damouse
Last active January 9, 2024 18:26
Show Gist options
  • Save damouse/71a67264b08fc56110c2fa91b49a01bf to your computer and use it in GitHub Desktop.
Save damouse/71a67264b08fc56110c2fa91b49a01bf to your computer and use it in GitHub Desktop.
Nginx wss reverse proxy on the back of letsencrypt
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
server_name mysite.com;
location /service/ {
proxy_pass http://localhost:8799/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
}
@damouse
Copy link
Author

damouse commented Sep 16, 2018

This allows a websocket server running on localhost:8799 to be exposed to the internet at large as `wss://mysite.com/service/' without having to configure the local server with TLS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment