Score:1

apache2.4 reverse proxy to nginx gitlab server

us flag

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

digijay avatar
mx flag
I'm afraid this question is off-topic for serverfault (Questions on Server Fault must be about managing information technology systems *in a business environment*) but anyway: Do you have `127.0.0.1 localhost` in `/etc/hosts` and port 1234 in `netstat -tulpen`?
CaptainJack42 avatar
us flag
What forum would be the right to post such questions than? Sry about that, but at this point there are too many subforums of stack overflow to keep track of what fits where for me^^. Anyway, yes 127.0.0.1 localhost is in etc/hosts and the ports are also open and running
digijay avatar
mx flag
I think your question was well asked, no-one complained and you got an answer - so stick with us :-) +1
ezra-s avatar
ru flag
ProxyPass already provides a parameter to specify a path, specifying it inside Location may give you issues, since proxypass and location are interpreted in the opposite order. Take this into consideration for future configurations.
Score:1
za flag

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.

CaptainJack42 avatar
us flag
That worked thx!
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.