1

I have a gitlab server next to my web server running on my home network. On my web server I run Apache2 with some domains. One of them is example.com. Now my aim is that the user receives the gitlab login page when visiting something like example.com/gitlab or gitlab.example.com. Actually I do not care whether the redirection happens from a certain url or a subdomain. I've already tried quite much but nothing of this worked for me (probably I did it wrong all times).

I also read some related forum posts like

But I didn't get anything up and running.

My default.conf is configured that it always redirects Port 80 to Port 443 (HTTPS).

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

    Redirect permanent / https://www.example.com/
    [...]
</VirtualHost>

So here is my example.com.conf before:

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

    DocumentRoot /var/www/html/example.com

    SSLEngine on

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
</VirtualHost>

First I tried to redirect from a certain url. I added:

ProxyRequests Off
ProxyPass /gitlab http://192.168.0.115:80/
ProxyPassReverse /gitlab http://192.168.0.115:80/

This does not work completly but if I enter the url, I get "404 The requested URL /users/sign_in was not found on this server". '/users/sign_in' is the path of the login page of my gitlab so server, so at least something seems to work. Strange to me is that it works if I redirect the root directory to my internal IP:

ProxyRequests Off
ProxyPass / http://192.168.0.113:80/
ProxyPassReverse / http://192.168.0.113:80/

This works but now I can't access my actual website anymore.

Then I tried redirection from a subdomain. I added:

<VirtualHost *:443>
    ServerName gitlab.example.com

    ProxyPass / http://192.168.0.113/
    ProxyPassReverse / http://192.168.0.113/
</VirtualHost>

But I receive "The website is unreachable". I don't even get the subdomain running.

2
  • <Location /gitlab> ProxyRequests Off ProxyPass / 192.168.0.113:80 ProxyPassReverse / 192.168.0.113:80 </Location> ? Jan 9, 2019 at 20:25
  • Thank you for your answer. I had to change it to <Location /gitlab> ProxyPass 192.168.0.113 ProxyPassReverse 192.168.0.113 </Location> because ProxyRequests is not allowed in Location and ProxyPass shall not specify any path within Location. Unfortunatly I get again the error "404 The requested URL /users/sign_in was not found on this server". If I change the Location to root (like this <Location />) then it works again. Any suggestions?
    – Kite
    Jan 10, 2019 at 7:35

1 Answer 1

0

Might have to use mod_rewrite to strip the /gitlab bit out. Something like:

rewriteBase "/gitlab"
rewriteRule "^gitlab/(.*)" "http:/192.168.0.113/$1" [P]

See https://httpd.apache.org/docs/2.4/rewrite/proxy.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .