GitLab SSH operations failing behind Nginx reverse proxy

148 Views Asked by At

I have set up a webserver (Nginx) as a reverse proxy for multiple servers, with one of them hosting GitLab CE on a VM. The reverse proxy is configured to redirect requests to the GitLab server using a subdomain, and everything seems to be working fine for HTTP requests.

However, when I attempt to perform GitLab operations using SSH (e.g., cloning, pulling, pushing), the operations fail. It appears that SSH is connecting to the Nginx server instead of the GitLab server since the domain initially points to the Nginx server.

Here's my Nginx configuration for the GitLab subdomain:

server {
    server_name gitlab.mydomain.com;

    location / {
        proxy_pass http://192.168.10.118:10987;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/gitlab.mydomain.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/gitlab.mydomain.com/privkey.pem; 
    include /etc/letsencrypt/options-ssl-nginx.conf; 
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 
}

server {
    if ($host = gitlab.mydomain.com) {
        return 301 https://$host$request_uri;
    } 
    listen 80;
    server_name gitlab.mydomain.com;
    return 404; 
}

How can I configure Nginx and GitLab to ensure that GitLab operations using SSH keys are directed to the GitLab server behind the Nginx reverse proxy?

Any insights or guidance on adjusting the Nginx and GitLab configurations would be greatly appreciated. Thank you!

0

There are 0 best solutions below