Apache 2.4 HTTPS Redirect首次使用后可以正常工作

时间:2018-05-03 13:21:38

标签: apache redirect mod-rewrite gitlab

我使用官方的Gitlab Apache 2.4模板进行gitlab安装。第一次访问git.example.com时,我得到超时。访问https://git.example.com后,即使访问git.example.com,重定向也能正常运行吗?

这是模板:

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

  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [NE,R,L]
</VirtualHost>

<VirtualHost *:443>
  SSLEngine on
  SSLProtocol all -SSLv2
  SSLHonorCipherOrder on
  SSLCipherSuite "ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS"
  Header add Strict-Transport-Security: "max-age=15768000;includeSubdomains"
  SSLCompression Off
  SSLCertificateFile /etc/httpd/ssl.crt/YOUR_SERVER_FQDN.crt
  SSLCertificateKeyFile /etc/httpd/ssl.key/YOUR_SERVER_FQDN.key
  SSLCACertificateFile /etc/httpd/ssl.crt/your-ca.crt

  ServerName YOUR_SERVER_FQDN
  ServerSignature Off

  ProxyPreserveHost On
  AllowEncodedSlashes NoDecode

  <Location />

    Require all granted    
    ProxyPassReverse http://127.0.0.1:8181
    ProxyPassReverse http://git.example.com/
  </Location>
  RewriteEngine on
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f [OR]
  RewriteCond %{REQUEST_URI} ^/uploads/.*
  RewriteRule .* http://127.0.0.1:8181%{REQUEST_URI} [P,QSA,NE]

  RequestHeader set X_FORWARDED_PROTO 'https'
  RequestHeader set X-Forwarded-Ssl on
  DocumentRoot /opt/gitlab/embedded/service/gitlab-rails/public
</VirtualHost>

0 个答案:

没有答案