Skip to content

Instantly share code, notes, and snippets.

@ciis0
Created January 23, 2026 14:09
Show Gist options
  • Select an option

  • Save ciis0/580e3e210d51d89812a61ca9d00ec48e to your computer and use it in GitHub Desktop.

Select an option

Save ciis0/580e3e210d51d89812a61ca9d00ec48e to your computer and use it in GitHub Desktop.
<VirtualHost *:8443>
ServerAlias *.my.localhost
SSLCertificateFile _.my.localhost.pem
SSLEngine On
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
RequestHeader set X-Forwarded-Port expr=%{SERVER_PORT}
RewriteEngine On
RewriteCond %{SERVER_NAME} "((.*)-)?(.*)-(.*)-(.*)-(.*).my.localhost"
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule (.*) http://%3.%4.%5.%6:8080$1 [P,L]
RewriteCond %{SERVER_NAME} "((.*)-)?(.*)-(.*)-(.*)-(.*).my.localhost"
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule (.*) ws://%3.%4.%5.%6:8080$1 [P,L]
RewriteCond %{SERVER_NAME} "(.*).my.localhost"
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule (.*) http://%1.wsl:8080$1 [P,L]
RewriteCond %{SERVER_NAME} "(.*).my.localhost"
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule (.*) ws://%1.wsl:8080$1 [P,L]
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment