我在我的个人服务器上设置了gitlab,并使用了这个答案和这个答案 (还有一些input来使它与我的apache安装一起工作。一切工作正常,当我去gitlab.example.com,我看到gitlab UI ,可以创build帐户等,但是当我检查了我转发的URI时,就是这样
https://gitlab.example.com//users/sign_in (注意域名后面的两个斜杠)。 这不是一个真正的问题,但我想知道这是为什么,我怎样才能解决这个问题 – 特别是因为当我从地址中删除一个斜线时,它工作的很好。 (所以https://gitlab.example.com/users/sign_in是完全一样的)。
事实上,我得到了两次转发:
GET https://gitlab.example.com => 301 Moved Permanently Location:https://gitlab.example.com/ GET https://gitlab.example.com/ => 302 Found Location:https://gitlab.example.com//users/sign_in 这是我的apacheconfiguration文件(`/etc/apache2/sites-enabled/gitlab.conf):
<IfModule mod_ssl.c> <VirtualHost *:443> ServerName gitlab.example.com ServerSignature Off ProxyPreserveHost On ProxyPassMatch ^(/[^/]+\.(html|png|ico|css|txt))$ ! ProxyPass /assets ! <Location /> Order deny,allow Allow from all ProxyPassReverse http://127.0.0.1:8080 ProxyPassReverse http://gitlab.example.com </Location> RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/%(REQUEST_FILENAME} !-f RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA] DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule>
这是gitlab的问题吗? 我怎样才能解决它?
注意:我绝对不确定哪个模块导致转发行为,如果您需要其他configuration文件,请告诉我。
你可能想尝试追加一个斜线/到ProxyPass目标URL的变化
ProxyPassReverse http://127.0.0.1:8080
成
ProxyPassReverse http://127.0.0.1:8080/
因为您正在将这些指令应用于也以终止斜线/ (或仅在这种情况下为斜线: <Location /> )终止的path,如手动警告:
如果第一个参数以/结尾,则第二个参数也应该以/结尾,反之亦然。 否则,由此产生的对后端的请求可能会错过一些所需的斜线,并且不能提供预期的结果。