2016-07-24 28 views
2

我已經安裝了最新的Gitlab-CE(8.10)在CentOS 7(全新安裝)通過總括包默認Gitlab端口:https://about.gitlab.com/downloads/#centos7改變,因爲這裏所描述

現在,我想更改默認端口爲哪一個可以訪問Gitlab網頁界面。爲此,我跟着指示在http://docs.gitlab.com/omnibus/settings/nginx.html#change-the-default-port-and-the-ssl-certificate-locations,即我的配置文件/etc/gitlab/gitlab.rb在包括

external_url "http://127.0.0.1:8765" 

,然後用gitlab-ctl reconfigure && gitlab-ctl restart更新配置。然而,當我然後導航到http://127.0.0.1:8765時,Gitlab保持重定向到http://127.0.0.1/users/sign_in,即,端口規範以某種方式被丟棄。然後,當我手動將瀏覽器中的URL更改爲http://127.0.0.1:8765/users/sign_in時,它會正確顯示登錄頁面,有趣的是,頁面上的所有鏈接(例如「Explore」,「幫助」)都包含端口規範。

爲了解決這個問題,是否有必要在/etc/gitlab/gitlab.rb以外的地方指定端口?

+0

奇怪:https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1210/diffs應該有固定的這個重新正確配置以及頭? (http://docs.gitlab.com/omnibus/settings/nginx.html#change-the-default-port-and-the-ssl-certificate-locations) – VonC

+0

@VonC有趣的是,根據你的建議,我只是取消註釋'/ etc/gitlab/gitlab.rb'中的'nginx ['proxy_set_headers']'的默認設置(也將'X-Forwarded-Proto'改爲'http'並移除'X-Forwarded-Ssl'),並突然它作品!我一定誤解了文檔,似乎表明唯一需要修改的是'external_url'。 – ewcz

+0

幹得好!我添加了一個答案,使文檔的特定部分更加明顯。 – VonC

回答

2

問題在這裏:https://gitlab.com/gitlab-org/gitlab-ce/issues/20131 解決方法: 加入這一行/etc/gitlab/gitlab.rb:

nginx['proxy_set_headers'] = { "X-Forward-Port" => "8080", "Host" => "<hostname>:8080" } 

替換端口和主機名與你的價值觀,那麼作爲root或使用sudo:

gitlab-ctl reconfigure 
gitlab-ctl restart 

它幫助我在Debian 8.5,從gitlab回購的gitlab-ce。

1

此外external_url的,文檔建議設置一些nginx的代理標題:

默認情況下,當您指定external_url,綜合-gitlab將設置假定這幾個NGINX代理頭在大多數環境中保持健康。

例如,綜合-gitlab將設置:

"X-Forwarded-Proto" => "https", 
"X-Forwarded-Ssl" => "on" 

(在external_url如果指定HTTPS模式)。

不過,如果你遇到這樣的情況你GitLab是一個更復雜的設置像後面的反向代理,你將需要調整代理頭,以避免像你想被拒絕或可以改變錯誤不驗證CSRF令牌的真實性已完成422無法處理。

這可以通過覆蓋默認標題來實現,例如。指定/etc/gitlab/gitlab.rb

nginx['proxy_set_headers'] = { 
    "X-Forwarded-Proto" => "http", 
    "CUSTOM_HEADER" => "VALUE" 
} 

保存文件並reconfigure GitLab以使更改生效。

這樣你可以指定你需要的NGINX支持的任何頭文件。

OP ewcz確認in the comments

我只是註釋掉的默認設置nginx['proxy_set_headers']/etc/gitlab/gitlab.rb(也改變X-Forwarded-Protohttp和刪除X-Forwarded-Ssl),突然它的作品!

0

我按照上面的註釋更改了etc/gitlab.rb,並且我的端口沒有更改

external_url http://localhost:13080/ 
... 
nginx['proxy_set_headers'] = { 
    "X-Real-IP" => "$remote_addr", 
    "X-Forwarded-For" => "$proxy_add_x_forwarded_for", 
    "X-Forwarded-Proto" => "https", 
    "X-Forwarded-Ssl" => "on", 
    "X-Forward-Port" => "13080", 
    "Host" => "localhost:13080" 
} 

gitlab-ctl reconfigure 
gitlab-ctl restart