我已经安装了 Gitlab CE 版本。我可以在 Gitlab 中找到捆绑的 nginx。但是我找不到单独重启 nginx 的方法。我试过sudo service nginx restart
了,但它给出了:
* Restarting nginx nginx [fail]
我检查了所有文件,但找不到解决方案。我正在尝试根据本教程将 vhost 添加到捆绑的 nginx 中。但我停留在了那一步。有没有其他方法可以将 vhost 添加到与 Gitlab 捆绑的 nginx 中?或者如何检查我的 nginx conf 是否工作?
编辑:我已经解决了 502 错误。
我尝试根据this doc使用NON-bundle nginx ,但是在我修改gitlab.rb
并运行之后sudo gitlab-ctl reconfigure
,我得到了502 Whoops, GitLab is taking too much time to respond.
错误。
这是我gitlab.conf
的nginx。
upstream gitlab {
server unix://var/opt/gitlab/gitlab-git-http-server/sockets/gitlab.socket fail_timeout=0;
#
}
server {
listen *:80;
server_name blcu.tk;
server_tokens off;
root /opt/gitlab/embedded/service/gitlab-rails/public;
client_max_body_size 250m;
access_log /var/log/gitlab/nginx/gitlab_access.log;
error_log /var/log/gitlab/nginx/gitlab_error.log;
# Ensure Passenger uses the bundled Ruby version
passenger_ruby /opt/gitlab/embedded/bin/ruby;
# Correct the $PATH variable to included packaged executables
passenger_env_var PATH "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin";
# Make sure Passenger runs as the correct user and group to
# prevent permission issues
passenger_user git;
passenger_group git;
# Enable Passenger & keep at least one instance running at all times
passenger_enabled on;
passenger_min_instances 1;
location / {
try_files $uri $uri/index.html $uri.html @gitlab;
}
location @gitlab {
# If you use https make sure you disable gzip compression
# to be safe against BREACH attack
proxy_read_timeout 300; # Some requests take more than 30 seconds.
proxy_connect_timeout 300; # Some requests take more than 30 seconds.
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://gitlab;
}
location ~ ^/(assets)/ {
root /opt/gitlab/embedded/service/gitlab-rails/public;
# gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
error_page 502 /502.html;
}