Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab Omnibus: how to redirect all requests to another domain

I migrated my Gitlab to a new domain. I'd like to redirect all HTTP requests from the old URL to the new one. Both domains currently point to the same server (using A DNS records).

I use Gitlab Omnibus package, with the bundled nginx install. How to do this?

like image 802
Spone Avatar asked Dec 24 '22 12:12

Spone


1 Answers

First, create /etc/nginx/conf.d/redirect.conf:

server {
  listen 80;
  server_name old-gitlab.mydomain.com;
  rewrite ^/(.*)$ http://new-gitlab.mydomain.com/$1 permanent;
}

(if the /etc/nginx/conf.d/ path does not exist, go ahead and create it)

Now edit the configuration file at /etc/gitlab/gitlab.rb to add the following line:

nginx['custom_nginx_config'] = "include /etc/nginx/conf.d/redirect.conf;"

Finally, run gitlab-ctl reconfigure to rewrite the nginx configuration and restart nginx.

like image 159
Spone Avatar answered Dec 29 '22 02:12

Spone