I got this working on my Docker OIDC proxy after a few tries. The tricky bit is to allow it to work when the proxied URI for websockets and normal HTTP is the same. If it were distinct we can simply have another ProxyPass
/ProxyPassReverse
combination before it.
To support this the Rewrite
engine is used to detect whether the Upgrade
and Conntextion
headers are set and if so proxy accordingly. The second tricky bit [though I am not sure why] is to put it after the ProxyPass
and ProxyPassReverse
directives.
Here is the code from https://github.com/trajano/docker-oidc-proxy/blob/master/oidc-proxy.conf in context
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule rewrite_module modules/mod_rewrite.so
...
ProxyPass "/" "http://${SERVICE_NAME}:${SERVICE_PORT}/"
ProxyPassReverse "/" "http://${SERVICE_NAME}:${SERVICE_PORT}/"
ProxyPreserveHost On
ProxyVia On
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://${SERVICE_NAME}:${SERVICE_PORT}%{REQUEST_URI} [P]
I was able to successfully verify this with a Jupyter notebook server which uses Web Sockets.