Apache-2.2

SSLLabs:嚴格傳輸安全(HSTS):伺服器提供了多個 HSTS 標頭

  • March 11, 2019

CentOS 6.8

阿帕奇 2.2


我有兩個網站在這個伺服器上執行(moodle 和 mahara)。出於某種原因,其中一個(moodle)的 ssllabs 測試恢復正常,但對於 mahara 網站,我收到以下警告:

Strict Transport Security (HSTS) Invalid Server provided more than one HSTS header

這是處理它們的 ssl.conf 文件:

#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailing information about these 
# directives see <URL:http://httpd.apache.org/docs/2.2/mod/mod_ssl.html>
# 
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#

LoadModule ssl_module modules/mod_ssl.so

#
# When we also provide SSL we have to listen to the 
# the HTTPS port in addition.
#
Listen 443

##
##  SSL Global Context
##
##  All SSL configuration in this context applies both to
##  the main server and all SSL-enabled virtual hosts.
##

#   Pass Phrase Dialog:
#   Configure the pass phrase gathering process.
#   The filtering dialog program (`builtin' is a internal
#   terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog  builtin

#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism 
#   to use and second the expiring timeout (in seconds).
SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout  300

#   Semaphore:
#   Configure the path to the mutual exclusion semaphore the
#   SSL engine uses internally for inter-process synchronization. 
SSLMutex default

#   Pseudo Random Number Generator (PRNG):
#   Configure one or more sources to seed the PRNG of the 
#   SSL library. The seed data should be of good random quality.
#   WARNING! On some platforms /dev/random blocks if not enough entropy
#   is available. This means you then cannot use the /dev/random device
#   because it would lead to very long connection times (as long as
#   it requires to make more entropy available). But usually those
#   platforms additionally provide a /dev/urandom device which doesn't
#   block. So, if available, use this one instead. Read the mod_ssl User
#   Manual for more details.
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
#SSLRandomSeed startup file:/dev/random  512
#SSLRandomSeed connect file:/dev/random  512
#SSLRandomSeed connect file:/dev/urandom 512

#
# Use "SSLCryptoDevice" to enable any supported hardware
# accelerators. Use "openssl engine -v" to list supported
# engine names.  NOTE: If you enable an accelerator and the
# server does not start, consult the error logs and ensure
# your accelerator is functioning properly. 
#
SSLCryptoDevice builtin
#SSLCryptoDevice ubsec

##
## SSL Virtual Host Context
##

NameVirtualHost *:443



# Mahara
<VirtualHost *:443>

Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"

DocumentRoot /var/www/html/mahara
ServerName mahara.mydomain.ac.uk:443

ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

SSLEngine on

SSLProtocol all -SSLv2 -SSLv3 -TLSv1.1 -TLSv1

SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!AES256-GCM-SHA384:!AES128-SHA256:!AES256-SHA:!DSS:!DES-CBC3-SHA:!ECDHE-RSA-DES-CBC3-SHA:!DHE-RSA-DES-CBC3-SHA:!AES256-SHA256:!AES128-SHA:!AES128-GCM-SHA256
SSLHonorCipherOrder on

SSLCertificateFile /etc/httpd/ssl_certs/moodle_mydomain_ac_uk.crt
SSLCertificateKeyFile /etc/httpd/ssl_certs/moodle.mydomain.ac.uk.key
SSLCertificateChainFile /etc/httpd/ssl_certs/root/qv_bundle.crt

</VirtualHost>


# Moodle
<VirtualHost *:443>

Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"

DocumentRoot "/var/www/html/moodle"
ServerName moodle.mydomain.ac.uk:443

ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

<IfModule !mod_auth_ntlm_winbind.c>
 LoadModule auth_ntlm_winbind_module modules/mod_auth_ntlm_winbind.so
</IfModule>

<Directory "/var/www/html/moodle/auth/ldap/">
 <FilesMatch "ntlmsso_magic\.php|test\.php">
   NTLMAuth on
   AuthType NTLM
   AuthName "Moodle NTLM Authentication"
   NTLMAuthHelper "/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp"
   NTLMBasicAuthoritative on
   require valid-user
 </FilesMatch>
</Directory>

SSLEngine on

SSLProtocol all -SSLv2 -SSLv3 -TLSv1.1 -TLSv1

SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!AES256-GCM-SHA384:!AES128-SHA256:!AES256-SHA:!DSS:!DES-CBC3-SHA:!ECDHE-RSA-DES-CBC3-SHA:!DHE-RSA-DES-CBC3-SHA:!AES256-SHA256:!AES128-SHA:!AES128-GCM-SHA256
SSLHonorCipherOrder on

SSLCertificateFile /etc/httpd/ssl_certs/moodle_mydomain_ac_uk.crt
SSLCertificateKeyFile /etc/httpd/ssl_certs/moodle.mydomain.ac.uk.key
SSLCertificateChainFile /etc/httpd/ssl_certs/root/qv_bundle.crt

</VirtualHost>      

除了 moodle 虛擬主機有一些關於 winbind 和 ntlm 的額外資訊之外,我很確定它們是相同的。

有誰知道為什麼我可能會針對其中一個虛擬主機而不是另一個收到此警告?

謝謝

Strict-Transport-Security如果使用 HTTPS,Mahara 會自行設置標頭:

htdocs/init.php:

header('X-Permitted-Cross-Domain-Policies: master-only');
if (is_https()) {
   header('Strict-Transport-Security: max-age=63072000');

只需從該虛擬主機的 Apache 配置中刪除標頭即可。

引用自:https://serverfault.com/questions/957757