Why my GitLab instance behind reverse proxy redirects clients to localhost?

Recently, I installed this amazing GitLab CE and it works just I expected.

I opened my GitLab within localhost with bundled nginx and exposed it with external nginx, which is installed in host os.
Most features are just works find. But, when I try to create a new snippet it redirects me to localhost and not public URL I configured.

For example:

## gitlab.rb

external_url 'localhost:8080'
## nginx config file
# ...

server_name git.example.com;

proxy_pass http://localhost:8080;

# ...

Configurations above makes GitLab to open its server within localhost and external nginx to expose it to the public via git.example.com.

And it suppose to do the same thing with snippets.
If I create snippet in git.example.com it should redirect me to git.example.com, but it redirects me to locahost:8080.

What am I missing? Is further config needed?
I suppose the reverse proxy configs in external nginx itself is not the problem since it works just fine with regular repositories.

Your Gitlab needs to use config options from the Gitlab docs here: NGINX settings | GitLab mostly this particular section (using a non bundled web server): NGINX settings | GitLab

Also I expect you shouldn’t be using localhost in your external_url as well. It should normally be the DNS name/fqdn of your machine/server. In fact if you did this, then you wouldn’t need an external NGINX.

1 Like

I setup with provided document and now it does not redirect to localhost but to the socket lol

image
*sy-l340 is the name of my local machine.

Where did I went wrong?

This is what I found:

image

  • /var/opt/gitlab/gitlab-rails/etc/gitlab.yml

I guess this file have something to do with snippets’ url.

And I think I need modify some configs from gitlab.rb like this.
This one is not for snippets’ though.

image

  • /etc/gitlab/gitlab.rb

This may be the answer but I don’t know what exactly should I do.

Now that I modified configurations below, it works like a charm!

  • /etc/gitlab/gitlab.rb
    image

And I can see the actual config file, which is gitlab.yml, is also have changed.

  • /var/opt/gitlab/gitlab-rails/etc/gitlab.yml
    image

How on earth didn’t I come up with this such simple idea?

Thanks!

1 Like