2015-12-05 229 views
-1

我有一個owncloud安裝程序,並且我試圖將永久HTTP重定向到https。將http重定向到https(https將http重定向到默認值)

嗯,當我輸入https://sub.domain.com時,我的https conf工作得很好。 但http://sub.domain.com重定向到debian apache默認頁面。

我也嘗試實現適當的嚴格傳輸安全HTTP標頭配置。

我的設置是:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    ServerName sub.domain.com 
    ServerAlias www.sub.domain.com 
    RewriteEngine On 
    RewriteCond %{HTTPS} off 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
    ErrorLog /var/www/owncloud/error.log 
</VirtualHost> 

<IfModule mod_ssl.c> 
    <VirtualHost _default_:443> 
     ServerAdmin [email protected] 
     ServerName sub.domain:443 
     DocumentRoot /var/www/owncloud/public_html 

     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 

     SSLEngine on 
     SSLCertificateFile /etc/ssl/cloud/sub.domain.com.crt 
     SSLCertificateKeyFile /etc/ssl/cloud/sub.domain.com.key 
     SSLCertificateChainFile /etc/ssl/cloud/sub.domain.com.ca-bundle 

     <FilesMatch "\.(cgi|shtml|phtml|php)$"> 
       SSLOptions +StdEnvVars 
     </FilesMatch> 
     <Directory /usr/lib/cgi-bin> 
       SSLOptions +StdEnvVars 
     </Directory> 
     <IfModule mod_headers.c> 
        Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" 
     </IfModule> 
     BrowserMatch "MSIE [2-6]" \ 
       nokeepalive ssl-unclean-shutdown \ 
       downgrade-1.0 force-response-1.0 
     # MSIE 7 and newer should be able to use keepalive 
     BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown 

    </VirtualHost> 
</IfModule> 

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

回答

0

的解決方案是不是*:80在第一行,用sub.domain.com:80。