apache2.4 reverse proxy to nginx gitlab server [closed]

I'm currently running an owncloud server based on a apache 2.4 webserver on my raspberry pi 4 8GB (working on dietpi 7.3) which works great i have a public domain setup and use letsencrypt to create certificates. I now want to also setup a gitlab server on this pi, the gitlab server is working and reachable inside my local network through it's IP address and it's port (192.168.1.234:1234). I've setup the external_url in /etc/gitlab/gitlab.rb to 127.0.0.1:1234 and ran gitlab-ctl reconfigure.

I now want to configure a reverse proxy from the apache server to point to the gitlab NGINX (edit for clarification: The reverse proxy should work from a relative url (mydomain.com/gitlab in my case)) server, so i've added the file gitlab.conf to /etc/apache2/sites-available/ and added the following to the file:

<VirtualHost *:80>
        ServerName mydomain.com
        ProxyRequests off
        <Location /gitlab>
                ProxyPass http://localhost:1234
                ProxyPassReverse http://localhost:1234
        </Location>
</VirtualHost>

<VirtualHost *:443>
        ServerName mydomain.com

        # Certificate
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/mydomain.com/fullchain.pem

        <Location /gitlab>
                ProxyPass  http://localhost:1234
                ProxyPassReverse http://localhost:1234
        </Location>
</VirtualHost>

The Problem is that this doesn't work.. going to mydomain.com/gitlab just leaves me with a 404 Not Found

(of course i also always restart apache2 with systemctl restart apache2 when i change something in the config and i've also added the site to the apache server with a2ensite gitlab.conf and i've also enabled the modules proxy and proxy_http with a2enmod)

I also now that i'll most likely face more issues like not displaying the correct URLs in gitlab and so on, but i have a general idea on how to fix those and would like to fix this first and start working on them once i face them.

Other resources on the internet haven't been too helpfull since nothing i found worked when i tried it so any help or insight on this is really appreciated.

/captainjack


Solution 1:

Since you're proxying to localhost, nginx cannot find the Host header anywhere, and your gitlab installations seems to be a non-default virtualhost. Try adding the

ProxyPreserveHost On

into your apache config. To both vhost sections.