Setting Up Gitlab Community With Apache Proxy

jasonr

Mon Jan 27 2025 06:38:37 PM PST

RHEL Based:

sudo yum update -y
sudo yum install -y curl policycoreutils openssh-server perl


curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

sudo yum install gitlab-ce -y

sudo nano /etc/gitlab/gitlab.rb

For gitlab.rb:
    external_url 'https://gitlab.<hostname>'
    nginx['enable'] = false

sudo gitlab-ctl reconfigure


apache setup (conf.d for RHEL, sites_available Debian):


<VirtualHost *:80>
    ServerName gitlab.<hostname>
    Redirect permanent / https://gitlab.aethermecha.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName gitlab.<hostname>

    RequestHeader set X-Forwarded-Proto "https"
    RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}s"
    RequestHeader set X-Forwarded-Host "%{HTTP_HOST}s"
    RequestHeader set Authorization "%{HTTP:Authorization}s"

    # Set the document root to serve static assets directly
    DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public/

    # Proxy settings for non-asset requests
    <Location />
        ProxyPass           http://127.0.0.1:8080/
        ProxyPreserveHost   On
        ProxyPassReverse    http://127.0.0.1:8080/
        Require all granted
    </Location>

    # Exclude /assets from being proxied and serve them directly
    <Location /assets>
        ProxyPass   !
        Require all granted
    </Location>

    # SSL configuration
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/gitlab.aethermecha.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/gitlab.aethermecha.com/privkey.pem
</VirtualHost>


sudo yum install -y mod_ssl
sudo systemctl restart httpd

sudo systemctl restart httpd
sudo gitlab-ctl restart



programming git gitlab