架构:源码安装, 数据库用mysql,网站用nginx
先复制nginx文件
[[email protected] git]# mv /home/git/gitlab/lib/support/nginx/gitlab /usr/local/nginx/conf/vhosts.d/gitlab.conf
然后编辑设置你的server_name,配置可以参考我以下配置.
坑一.nginx报错
2016/07/19 09:26:11 [crit] 3881#0: *10 connect() to unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket failed (13: Permission denied) while connecting to upstream, client: 192.168.1.180, server: www.gitlab810.com, request: "GET / HTTP/1.1", upstream: "http://unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket:/", host: "www.gitlab810.com" 2016/07/19 09:26:11 [error] 3881#0: *10 open() "/home/git/gitlab/public/502.html" failed (13: Permission denied), client: 192.168.1.180, server: www.gitlab810.com, request: "GET / HTTP/1.1", upstream: "http://unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket/", host: "www.gitlab810.com"
这是因为我的nginx使用的是www用户运行,而/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket/用户组是git,
解决方案:把git加入www用户组,并赋予实行权限
usermod -a -G git www chmod g+rx /home/git/
坑二:nginx正确的配置
[[email protected] git]# cat /usr/local/nginx/conf/vhosts.d/gitlab.conf |grep -v ‘#‘ upstream gitlab-workhorse { server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0; } server { listen 80 ; server_name www.gitlab810.com; server_tokens off; access_log logs/gitlab_access.log; error_log logs/gitlab_error.log; location / { client_max_body_size 0; gzip off; proxy_read_timeout 300; proxy_connect_timeout 300; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://gitlab-workhorse; } error_page 404 /404.html; error_page 422 /422.html; error_page 500 /500.html; error_page 502 /502.html; error_page 503 /503.html; location ~ ^/(404|422|500|502|503)\.html$ { root /home/git/gitlab/public; internal; } }
注意第55行:proxy_set_header Host $http_host; 要修改成自己的server_name或者 $http_host.
时间: 2024-10-29 02:46:21