0

I'm not sure if it's possible what I'm trying to do but I have a few applications on multiple servers. I have one server for gitlab, one for jenkins and one for sonarqube. I want to be able to navigate to them by using my domain as follows:

gitlab > https:// git.mydomain.com
jenkins > https:// jenkins.mydomain.com
sonarqube > http:// sonar.mydomain.com

What I'm trying to do is setup a reverse proxy with apache2 on a 4th server that runs independent from the applications. Here is what I tried to do:

<VirtualHost *:80>
    ServerName http:// mydomain.com
    ProxyPass http:// sonar.mydomain.com/ http:// sonar.mydomain.com:9000/
    ProxyPassReverse http:// sonar.mydomain.com http:// sonar.mydomain.com:9000/
    ProxyPass http:// jenkins.mydomain.com/ https:// jenkins.mydomain.com:8081/
    ProxyPassReverse http:// jenkins.mydomain.com/ https:// jenkins.mydomain.com:8081/
</VirtualHost>

When I do it this way it won't work it will just go to the apache default page. What I did try is doing it with / and I noticed that it won't work with https:// extentions no matter in what way I try to set it. Is there a way to get this working?

and is it possible to set the proxy up the way I want?

NoSixties
  • 111

2 Answers2

1

it won't work with https:// extentions no matter in what way I try to set it

Your <VirtualHost *:80> is only matching port 80 traffic, so it cannot work with "https:// extentions."

Whatever problem there might be with your proxy setup, your first issue is with your virtual host setup.

EDIT per OP comment to answer:

what I want to do is redirect to https when someone tries to access the http

In this case, you should consider just doing a simple Redirect, rather than trying to set up a proxy:

<VirtualHost *:80>
  ServerName jenkins.mydomain.com
  Redirect permanent / https://jenkins.mydomain.com
<VirtualHost *:80>

<VirtualHost *:443>
  ServerName jenkins.mydomain.com
  * * * * *
  EVERY DIRECTIVE YOU WANT TO SET UP THE HTTPS SERVER
  * * * * *
<VirtualHost *:80>
Colt
  • 2,127
0

The typical config is that your users/visitors browse to http://www.example.com.com/sonar and then they get the content reverse proxied from http://sonar.example.com:9000/.

<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com

    ProxyPass /sonar http://sonar.example.com:9000/
    ProxyPassReverse /sonar http://sonar.example.com:9000/

    ProxyPass /jenkins https://jenkins.example.com:8081/
    ProxyPassReverse /jenkins https://jenkins.example.com:8081/
</VirtualHost>

And then repeat the same in the TLS virtualhost entry:

<VirtualHost *:443>
    ServerName www.example.com
    ServerAlias example.com

    ProxyPass /sonar http://sonar.example.com:9000/
    ProxyPassReverse /sonar http://sonar.example.com:9000/

    ProxyPass /jenkins https://jenkins.example.com:8081/
    ProxyPassReverse /jenkins https://jenkins.example.com:8081/
</VirtualHost>
HBruijn
  • 84,206
  • 24
  • 145
  • 224