Apache Reverse Proxy with Subdirectory


#1

Hey Guys,

i am trying to get a rocket.chat instance behind and Apache Reverse-Proxy running.
The Proxy is protected with an basic auth, which works fine.
The main problem is, that i have to run it in a subdirectory, which is not covered by the documentation.

So rocket.chat is configured on a dedicated VM:

ROOT_URL=https://sub.domain.org/chat/ 
IP-Adresse 192.168.100.7 
Port 3000

The Reverse Proxy is configured as follows:

<Location /chat>
      RewriteEngine On
      RewriteCond %{HTTP:Upgrade} =websocket [NC]
      RewriteRule /chat/(.*)           ws://192.168.100.7:3000/chat/$1 [P,L]
      RewriteCond %{HTTP:Upgrade} !=websocket [NC]
      RewriteRule /chat/(.*)           http://192.168.100.7:3000/chat/$1 [P,L]

     ProxyPass "http://192.168.100.7:3000/chat"
     ProxyPassReverse "http://192.168.100.7:3000/chat"
   </Location>

I can access rocket.chat via sub.domain.org/chat/ and can login!
But i see an error regarding:
https://sub.domain.org/chat/api/v1/commands.list
with status code 401 Unauthorized.
Further no images (like avatars) are shown and i also get a 401 error.

If i remove the RewriteConds and Rewrite Rules i get 401 errors from the following

wss://sub.domain.org/chat/sockjs/685/sd6zx5fu/websocket
https://sub.domain.org/chat/api/v1/commands.list 

For every 401 error i get a login window from my basic auth, which is quite annoying…

What did i miss in my proxy config.

Thanks in advance!