apache Gitlab加载时出现错误502...这正常吗?

lymnna71  于 2022-11-16  发布在  Apache
关注(0)|答案(3)|浏览(174)

当我用sudo gitlab-ctl restart(Debian杰西)重启gitlab服务器时,服务器正在加载,我得到了502错误,而不是“部署”页面。然后一切都正常。我不明白为什么会发生这种情况。

请注意,只有在加载时才会显示此信息,然后一切正常。我不满意,因为我以前得到的“部署”页面更好。

这是在我配置gitlab通过gitlab-workhorse来运行apache服务器代理后发生的(在此之前,我的web界面通信出现了很大的问题。快照下载无法正常工作,但现在一切都很好)。在修复这个问题之前,我使用gitlab的nginx代理。
我目前使用的apache配置如下,它符合standard configuration of Gitlab

<VirtualHost *:443>
  ServerName git.example.com
  ServerSignature Off

  ProxyPreserveHost On

  # Ensure that encoded slashes are not decoded but left in their encoded state.
  # http://doc.gitlab.com/ce/api/projects.html#get-single-project
  AllowEncodedSlashes NoDecode

  <Location />
    # New authorization commands for apache 2.4 and up
    # http://httpd.apache.org/docs/2.4/upgrading.html#access
    Require all granted

    #Allow forwarding to gitlab-workhorse
    ProxyPassReverse http://127.0.0.1:8283
    ProxyPassReverse https://git.example.com/

  </Location>

  RewriteEngine on

  #Don't escape encoded characters in api requests
  RewriteCond %{REQUEST_URI} ^/api/v3/.*
  RewriteRule .* http://127.0.0.1:8283%{REQUEST_URI} [P,QSA,NE]

  #Forward all requests to gitlab-workhorse except existing files like error documents
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
  RewriteCond %{REQUEST_URI} ^/uploads/.*
  RewriteRule .* http://127.0.0.1:8283%{REQUEST_URI} [P,QSA]

  # needed for downloading attachments
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public

  #Set up apache error documents, if back end goes down (i.e. 503 error) then a maintenance/deploy page is thrown up.
  ErrorDocument 404 /404.html
  ErrorDocument 422 /422.html
  ErrorDocument 500 /500.html
  ErrorDocument 503 /deploy.html

  #... ssl config

  RequestHeader set X_FORWARDED_PROTO 'https'
  RequestHeader set X-Forwarded-Ssl on

  LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
  ErrorLog  /home/myuser/logs/gitlab_error.log
  CustomLog /home/myuser/logs/gitlab_forwarded.log common_forwarded
  CustomLog /home/myuser/logs/gitlab_access.log combined env=!dontlog
  CustomLog /home/myuser/logs/gitlab.log combined

</VirtualHost>

我唯一更改的配置是我的/etc/gitlab/gitlab.rb,我这样做是为了让代理工作。

external_url 'https://git.example.com'
nginx['enable'] = false
web_server['external_users'] = ['www-data']
gitlab_workhorse['listen_network'] = "tcp"
gitlab_workhorse['listen_addr'] = "127.0.0.1:8283"

我做错了什么,得到了502错误,而不是漂亮的“部署”页面,我用来之前得到这些变化?
如果您需要任何其他信息,请询问。

1wnzp6jl

1wnzp6jl1#

通常我会在gitlab-ctl start之后看到此页面。

我的解决方案是

sudo gitlab-ctl start

sudo gitlab-ctl reconfigure

刷新浏览器:)

goqiplq2

goqiplq22#

好吧,从技术上讲,这是它应该工作的方式,毕竟这是一个502错误。如果你想显示部署页面,有一个手动的方法来设置它之前,每次重新启动:

gitlab-ctl deploy-page up

等一下再接着:

gitlab-ctl deploy-page down

否则,您可以在Apache配置中添加:

ErrorDocument 502 /deploy.html

它将在每次发生502错误时显示部署页面。

gopyfrb3

gopyfrb33#

配置服务器防火墙以允许http和https:

sudo ufw enable
sudo ufw allow http
sudo ufw allow https
sudo ufw allow OpenSSH
sudo ufw status

Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
443/tcp                    ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
443/tcp (v6)               ALLOW       Anywhere (v6)

相关问题