Skip to content

Instantly share code, notes, and snippets.

@milo
Created November 22, 2017 11:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milo/c0a9d34dd2e5990ef3f990639d4ec760 to your computer and use it in GitHub Desktop.
Save milo/c0a9d34dd2e5990ef3f990639d4ec760 to your computer and use it in GitHub Desktop.
Apache proxy to localhost port with WebSockets
#
# Proxy for local running .NET application on port 5000
#
# a2enmod proxy proxy_http proxy_wstunnel
#
<VirtualHost *:443>
ServerName example.com
ServerAdmin webmaster@example.com
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade$ [NC]
RewriteCond %{HTTP:Upgrade} ^WebSocket$ [NC]
RewriteRule .* ws://localhost:5000%{REQUEST_URI} [P]
Include ssl-common.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment