Score:1

Hide path in URL of Rocket.Chat with mod_rewrite

cn flag

I have been looking for a solution to my problem for days. Unfortunately without success. Before I try now days further around and it in the end no solution I ask you.

On my Univention server I have installed the app "Rocket.Chat". This installs itself as a Docker container.

I have created a subdomain 'chat.example.com' for Rocket.Chat which points to the Univention server. To call Rocket.Chat I have to enter in the browser:

https://chat.example.com/rocketchat/home

I do not like this. I would like it so that when I:

https://chat.example.com

I get directly to Rocket.Chat. I have also managed this with MOD_REWRITE. But then the browser shows the complete URL (https://chat.example.com/rocketchat/home) again.

To prevent this I have tried the following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^chat.example.com$ [NC]
RewriteRule ^/(.*)$ /rocketchat/home/ [P,L]

Where am I making the mistake?

with best

Score:0
cn flag

Thanks already for the support! I am in the process of trying to understand mod_rewrite. I just looked at the apache doc on mod_proxy. I guess that I don't need the P flag as I only ever want to rewrite the URL.

If I understand the doc correctly the example as I did would: P flag without "ProxyPass" and "ProxyPassReverse" wouldn't make any sense either, would it?

With "root directory" you mean that of the app or the web server or VHOST configured there? That is in a Docker container, after all. Or by "root directory" do you mean that of the VHOST "outside" of Docker, i.e. on the Univention server that I'm trying to configure here right now?

So I need to prepend "\" in front of each item in the RewriteCond?

Whether "home" is a physical directory I don't know. I just see it as a result in the browser. I opened the shell of the Docker container but I didn't find any web server configuration there.

I then tried it as follows. Once with ...home/ and with ..home.

The result is always the same:

Not Found The requested URL was not found on this server.

Score:0
cn flag

To test the status of Rocket.Chat I can enter the following on the Univention host.

root@gw01:~# curl -i http://127.0.0.1:40001/rocketchat/api/info
HTTP/1.1 200 OK
X-XSS-Protection: 1
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
Content-Security-Policy: default-src 'self' ; connect-src *; font-src 'self'  data:; frame-src *; img-src * data:; media-src * data:; script-src 'self' 'unsafe-eval' ; style-src 'self' 'unsafe-inline' 
X-Instance-ID: QkBHePxDKXAd2ZaNk
Cache-Control: no-store
Pragma: no-cache
content-type: application/json
access-control-allow-origin: *
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, X-User-Id, X-Auth-Token
Vary: Accept-Encoding
Date: Sat, 19 Feb 2022 10:54:44 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked

{"version":"3.18.2","success":true}

Maybe this will help?

Score:0
kz flag
RewriteCond %{HTTP_HOST} ^chat.example.com$ [NC]
RewriteRule ^/(.*)$ /rocketchat/home/ [P,L]

A few queries with this:

  • Why are you using the P flag? This uses mod_proxy to proxy the request?
  • This matches every URL and rewrites to a single URL? Your example only mentions rewriting the root only?
  • Your example does not include a trailing slash on the target, but you have included a trailing slash on this rule? Is home a physical subdirectory?

Try the following instead, assuming this rule is in a server (or virtualhost) context:

RewriteCond %{HTTP_HOST} ^chat\.example\.com [NC]
RewriteRule ^/$ /rocketchat/home/ [L]

However, whether this works may still be dependent on the chat app itself.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.