Using gitlab behind Apache proxy all generated urls are wrong

Posted by Hippyjim on Server Fault See other posts from Server Fault or by Hippyjim
Published on 2014-08-19T08:30:24Z Indexed on 2014/08/19 16:22 UTC
Read the original article Hit count: 270

Filed under:
|

I've set up Gitlab on Ubuntu 12.04 using the default package from https://about.gitlab.com/downloads/

{edit to clarify}

I've set up Apache to proxy and run the nginx server the package installed on port 8888 (or so I thought).

As I had Apache installed already I have to run nginx on localhost:8888. The problem is, all images (such as avatars) are now served from http://localhost:8888, and all the checkout urls Gitlab gives are also localhost - instead of using my domain name.

If I change /etc/gitlab/gitlab.rb to use that url, then Gitlab stops working and gives a 503.

Any ideas how I can tell Gitlab what URL to present to the world, even though it's really running on localhost?

/etc/gitlab/gitlab.rb looks like:

# Change the external_url to the address your users will type in their browser
external_url 'http://my.local.domain'
redis['port'] = 6379
postgresql['port'] = 2345
unicorn['port'] = 3456

and /opt/gitlab/embedded/conf/nginx.conf looks like:

server {
        listen       localhost:8888;
        server_name  my.local.domain;

[Update]

It looks like nginx is still listening on the wrong port if I don't specify localhost:8888 as the external_url. I found this in /var/log/gitlab/nginx/error.log

2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/08/19 14:29:58 [emerg] 2526#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2014/08/19 14:29:58 [emerg] 2526#0: still could not bind()

Apache setup looks like:

<VirtualHost *:80>
  ServerName my.local.domain

  ServerSignature Off
  ProxyPreserveHost On

  AllowEncodedSlashes NoDecode

  <Location />
    ProxyPass http://localhost:8888/ 
    ProxyPassReverse http://127.0.0.1:8888
    ProxyPassReverse http://my.local.domain
  </Location>
</VirtualHost>

Which seems to proxy everything back ok if Gitlab listens on localhost:8888 - I just need Gitlab to start displaying the right URL, instead of localhost:8888.

© Server Fault or respective owner

Related posts about apache-2.4

Related posts about gitlab