Search code examples
apachelaravel-echo

Pass Multiple Parameters From Redirect URL In Apache Proxy Reverse


I'm running an app that utilizes laravel-echo-server. So for me to run it on my production server over https I need to use apache proxy reverse to redirect my /tools/socket.io/ urls to http://localhost:6001.

While that is working fine I keep getting this error Cannot Post / because I need to pass along the params from my domain url to my reverse proxy url. Here is my apache config:

ProxyPreserveHost On
ProxyRequests off
ProxyPass /tools/socket.io/ http://localhost:6001/
ProxyPassReverse /tools/socket.io/ http://localhost:6001/

I came across this post stack overflow but the implementation didn't work for me.

So this are the parameters I need to pass and their values are dynamic EIO transport t. and my url is like

https://exampledomain.com/tools/socket.io/?EIO=3&transport=polling&t=Ml8lZDJ


Solution

  • Here's my apaxhe config within my SSL virtualhost for my domain:

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