I've been trying unsuccessfully for a few days to setup a reverse proxy to a localhost websocket url.
ProxyPass /chat/stream/ wss://localhost:8000/chat/stream/
ProxyPassReverse /chat/stream/ wss://localhost:8000/chat/stream/
I get an error in the apache error_log that reads:
No protocol handler was valid for the URL /chat/stream/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
I have read countless pages via google of people using this method so I wonder if there is some issue in our setup/install of Apache that ships with Server.app 5.2?
I have all the standard modules loaded in httpd_server_app.conf
mod_proxy mod_proxy_wstunnel mod_proxy_http ...
Can anyone shed some light on this?
Thanks
Adam
Take a look at the ReadMe.txt file in /Library/Server/Web/Config/apache2/
It writes about the new proxy service where requests first go to an http server running on port 80 and 443, which are then forwarded to internal ports 34580 and 34543.
For the wstunnel module there's a conflict with the mod proxy module, where mod proxy will strip out tunnel headers (https://lists.gt.net/apache/users/393509). I confirmed this by changing the LogFormat in apache_serviceproxy.conf by adding to LogFormat
I did the same in httpd_server_app.conf and could see the Connection and Upgrade websocket headers were being removed before getting to my webapp.
The fix was merely to add a file in /Library/Server/Web/Config/Proxy for my application. Look at the last line in apache_serviceproxy.conf to see the expected naming format. In my case the file is called apache_serviceproxy_customsites_ws.conf
The contents:
This will forward the ws request to the expected internal https port 34543 and retain the headers. You must forward it to 34543 or 34580. And also note the path is included so that it can be picked up in the next step.
Then, in my webapp_script (the include file for my webapp) I have:
This forwards the request to my websocket server running on port 61614.
With that, it's now working as expected.