Gitlab Omnibus:如何将所有请求重定向到另一个域 [英] Gitlab Omnibus: how to redirect all requests to another domain
问题描述
我将自己的Gitlab迁移到了新域.我想将所有HTTP请求从旧的URL重定向到新的URL.当前两个域都指向同一台服务器(使用A
DNS记录).
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).
我将Gitlab Omnibus软件包与捆绑的nginx安装一起使用. 该怎么做?
I use Gitlab Omnibus package, with the bundled nginx install. How to do this?
推荐答案
首先,创建/etc/nginx/conf.d/redirect.conf
:
server {
listen 80;
server_name old-gitlab.mydomain.com;
rewrite ^/(.*)$ http://new-gitlab.mydomain.com/$1 permanent;
}
(如果/etc/nginx/conf.d/
路径不存在,请继续创建它)
(if the /etc/nginx/conf.d/
path does not exist, go ahead and create it)
现在在/etc/gitlab/gitlab.rb
处编辑配置文件以添加以下行:
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;"
最后,运行gitlab-ctl reconfigure
重写nginx配置并重新启动nginx.
Finally, run gitlab-ctl reconfigure
to rewrite the nginx configuration and restart nginx.
这篇关于Gitlab Omnibus:如何将所有请求重定向到另一个域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!