I have a server with apache(2.4.18) installed
I have installed multiple applications on the server like Grafana, Sonarqube, and MySQL enterprise monitor(MEM)
Each application has URL like this
http://test.com:9000
http://test.com:3000
I am looking for a solution which allows me to redirect this URL with the port to URL with context, something like that
http://test.com:9000 --> http://test.com/sonar
http://test.com:3000 --> http://test.com/grafana
I have added some code in /etc/apache2/sites-enabled/000-default.conf file
Redirect permanent /sonar http://test.com:9000
Redirect permanent /grafana http://test.com:3000
but when I enter http://test.com/sonar
in the web browser it redirects to http://test.com:9000
URL only
I want http://test.com/sonar
this URL to persists on Web browser
2
Answers
You need to proxy requests and not redirect them.
Use a ProxyPass directive as mentioned in the official apache proxy documentation
For example add this location block inside your configuration:
If you use
Redirect permanent
, server will send301
response back to client (along with newLocation
). That will result in browser issuing a new request, this time to new Location, and also new location will be shown in browser address bar.What you need is Reverse Proxy. For this you need to make sure that mod_proxy is enabled in your apache configuration (usually it is enabled by default), and put something like this in your
.conf
file:You will probably also have to make your applications aware that they are running under non-root context (by making some configuration changes):
http://docs.grafana.org/installation/behind_proxy/
https://docs.sonarqube.org/latest/setup/install-server/