Score:0

Apache URL rewrite to hide port numbers of web servers

et flag

I have an Ubuntu server running Gitea and Jenkins on ports 3000 and 4000 respectively. I want to be able to access them through a user friendly url like http://myhost/gitea and http://myhost/jenkins.

I tried using URL rewrite with the following rule.

RewriteRule ^/gitea http://myhost:3000/$1 [L,R]

However it only redirects me to http://myhost:3000/ when I input http://myhost/gitea in the browser. How should I write my rule so that I can always see the app name instead of the ports? (ex: http://myhost/gitea/login, http://myhost/gitea/explore/repos, etc.)

HBruijn avatar
in flag
The typical approach to achieve that is a reverse proxy configuration with [mod_proxy](https://httpd.apache.org/docs/2.4/mod/mod_proxy.html) and `ProxyPass /gitea http://myhost:3000/` and `ProxyPassReverse /gitea http://myhost:3000/`
John Hanley avatar
cn flag
Port numbers are a critical part of a URL. By convention, ports 80 and 443 are not displayed. If you want public connections on different port numbers than the connection **MUST** specify the port number. A better strategy is to implement a reverse proxy that listens on the standard ports 80/443 and forwards traffic to your application on whatever port number you want.
I sit in a Tesla and translated this thread with Ai:

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.