Apache Ubuntu16.04上的Gitlab ce以及子域上的letsencrypt

Apache Ubuntu16.04上的Gitlab ce以及子域上的letsencrypt,apache,gitlab,subdomain,ubuntu-16.04,lets-encrypt,Apache,Gitlab,Subdomain,Ubuntu 16.04,Lets Encrypt,我在运行Ubuntu 16.04的v服务器上安装了gitlab ce,apache作为Web服务器。git.example.com下的gitlab安装工作正常,我可以通过http设置我的用户 我正在这个服务器上运行example.com网站,cloud.example.com下的nextcloud实例和git.example.com下的gitlab,我决定使用letsencrypt letsencrypt for example.com和cloud.example.com的安装工作正常。我使用的

我在运行Ubuntu 16.04的v服务器上安装了gitlab ce,apache作为Web服务器。git.example.com下的gitlab安装工作正常,我可以通过http设置我的用户

我正在这个服务器上运行example.com网站,cloud.example.com下的nextcloud实例和git.example.com下的gitlab,我决定使用letsencrypt

letsencrypt for example.com和cloud.example.com的安装工作正常。我使用的配置,但它不能正常工作。当我尝试在重定向下访问gitlab时,https部分会将我重定向到,但我不知道为什么

这是服务器响应

Request URL:https://git.example.com/
Request Method:GET
Status Code:302 Found
Remote Address:*:443
Referrer Policy:no-referrer-when-downgrade
HTTP/1.1 302 Found
Date: Sat, 03 Mar 2018 10:36:24 GMT
Server: Apache/2.4.18 (Ubuntu)
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
Location: http://example.com
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Request-Id: bdfffb7e-1c89-4308-be13-5c35a64f31f3
X-Runtime: 0.010298
X-Ua-Compatible: IE=edge
X-Xss-Protection: 1; mode=block
Content-Length: 90
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
以下是我的apache配置文件:

<VirtualHost git.example.com:80>
  ServerName git.example.com
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public/
  ServerSignature Off

  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteCond %{SERVER_NAME} =git.example.com
  RewriteCond %{REQUEST_URI} !^/.well-known/.*
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]

</VirtualHost>
但到目前为止,寻找这个对我没有帮助。我想在apache决定根目录到domain.net时,会出现某种循环,但我找不到它的源代码

如果有人知道在哪里查找错误,或者知道我的配置有什么问题,我将不胜感激

答复

旋度-v

是:


所以我相信Gitlab本身存在一些配置错误,我发现了一个提示,这就是问题所在

gitlab本身的设置是错误的。登录限制越来越严格,因此我必须使用git.example.com/users/Sign_-in直接链接登录并更改设置。现在它开始工作了

多亏了杜桑·巴吉奇

加成


还有一个问题是,“主页URL”的设置被设置为我的主域。我不得不把它改成。我刚刚忘记了一个简单的设置

这些答案可能会有帮助我不明白这个答案的哪一部分可能会有帮助。你能更具体地说明我的问题的答案是什么吗?谢谢。也许您的GitLab配置了错误的主机名?(这可能会导致这样的重定向)我检查过了。每个配置中的主机名都是git.example.com。如果直接在实例shell中尝试
curl-v,那么响应是什么http://127.0.0.1:8181
<IfModule mod_ssl.c>
<VirtualHost git.example.com:443>
    SSLEngine on
    SSLCipherSuite    SSLv3:TLSv1:+HIGH:!SSLv2:!MD5:!MEDIUM:!LOW:!EXP:!ADH:!eNULL:!aNULL
    SSLCertificateFile /etc/letsencrypt/live/git.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/git.example.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

    ServerName git.example.com
    ServerSignature Off
    ProxyPreserveHost On
    ProxyPass / https://localhost:8181/
    ProxyPassReverse / https://git.example.com:8181/

    # http://doc.gitlab.com/ce/api/projects.html#get-single-project
    AllowEncodedSlashes NoDecode

    <Location />
        # Apache 2.2
        Order allow,deny
        Allow from all

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

    <Directory /opt/gitlab/embedded/service/gitlab-rails/public/>
       Require all granted
    </Directory>

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

    RewriteEngine on

    # Apache equivalent of nginx try files
    RewriteCond %{DOCUMENT_ROOT}/{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_URI} ^/uploads/.* [OR]
    RewriteCond %{REQUEST_URI} !/\.well-known/.*
    RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]

    RequestHeader set Host "git.example.com"
    RequestHeader set X-Forwarded-Ssl on
#    RequestHeader set X-Forwarded-For %<span class="pl-s1"><span class="p1-    pse">{</span>REMOTE_ADDR<span class="ps1-pse">}</span></span>e  
    RequestHeader set X_FORWARDED_PROTO 'https'

    #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 502 /502.html
    ErrorDocument 503 /503.html

    # It is assumed that the log directory is in /var/log/httpd.
    # For Debian distributions you might want to change this to
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
</IfModule>
Started GET "/" for 93.200.218.17 at 2018-03-03 11:34:31 +0100
Processing by RootController#index as HTML
Redirected to http://example.com
Filter chain halted as :redirect_unlogged_user rendered or redirected
Completed 302 Found in 4ms (ActiveRecord: 0.0ms)
> GET / HTTP/1.1
> Host: 127.0.0.1:8181
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: no-cache
< Content-Type: text/html; charset=utf-8
< Date: Mon, 05 Mar 2018 09:58:40 GMT
< Location: http://example.com
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-Request-Id: 17cb8d7d-918f-4d72-95ca-f6262e7537b2
< X-Runtime: 0.015595
< X-Ua-Compatible: IE=edge
< X-Xss-Protection: 1; mode=block
< Content-Length: 90
<
* Connection #0 to host 127.0.0.1 left intact
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
gitlab-wo 312  git    3u  IPv4 188680      0t0  TCP localhost:8181 (LISTEN)