0

The Lounge gives an example to use a reverse proxy with Apache.

RewriteEngine On
RewriteRule ^/irc$ /irc/ [R]
RewriteCond %{REQUEST_URI}  ^/irc/socket.io        [NC]
RewriteCond %{QUERY_STRING} transport=websocket    [NC]
RewriteRule /irc/(.*)       ws://127.0.0.1:9000/$1 [P,L]

RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
ProxyVia On
ProxyRequests Off
ProxyAddHeaders On
ProxyPass /irc/ http://127.0.0.1:9000/
ProxyPassReverse /irc/ http://127.0.0.1:9000/

# By default Apache times out connections after one minute
ProxyTimeout 86400 # 1 day

It uses a subfolder, but I would rather have a subdomain. Like…

https://irc.domain.tld

Instead of…

https://domain.tld/irc/

Regex feels incredibly complex for someone who's just trying to set up a nice service for their friends… After so many failed attempts, I would really like some help! Please, pretty please?

Thanks for reading <3

1 Answer 1

1

This is not about The Lounge or reverse proxy, but how Apache handles virtual hosting. The official documentation even has examples for common setups, including Using Virtual_host and mod_proxy together.

<VirtualHost *:443>
    ServerName irc.example.com

    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
    RewriteCond %{QUERY_STRING} transport=websocket    [NC]
    RewriteRule /(.*)           ws://127.0.0.1:9000/$1 [P,L]

    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
    ProxyVia On
    ProxyRequests Off
    ProxyAddHeaders On
    ProxyPass / http://127.0.0.1:9000/
    ProxyPassReverse / http://127.0.0.1:9000/

    # By default Apache times out connections after one minute
    ProxyTimeout 86400 # 1 day
</VirtualHost>

The mod_rewrite is only required to allow both HTTP and Websocket connections. If you only need the Websocket, the configuration for it becomes a lot easier, as demonstrated in mod_proxy_wstunnel:

<VirtualHost *:443>
    ServerName irc.example.com
    ProxyPass / ws://127.0.0.1:9000/
</VirtualHost>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .