







这个主机完整是 https://192.168.89.41:8080
我想别人在访问 http://192.168.89.41:8080,自动跳往 https://192.168.89.41:8080 但按目前调试的配置,访问 http://192.168.89.41:8080,浏览器会显示出一个 html 的代码明文:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
Instead use the HTTPS scheme to access this URL, please.<br />
<blockquote>Hint: <a href="https://localhost:8080/"><b>https://localhost:8080/</b></a></blockquote></p>
</body></html>
下面是节选 httpd.conf,配置有多个 VirtualHost,但是只想 8080 这个主机启用 https, mod_ssl 确定是装好的,证书已经使用上的了,
cat /etc/httpd/conf/httpd.conf
#8080,Test
<VirtualHost *:8080>
SSLEngine on
SSLCertificateFile "/etc/httpd/conf/ssl_key/server.crt"
SSLCertificateKeyFile "/etc/httpd/conf/ssl_key/server.key"
SSLOptions StdEnvVars
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW:!RC4:
DocumentRoot /opt/test1
DocumentRoot "/opt/test1"
<Directory "/opt/test1">
Options Indexes FollowSymLinks
#Options FollowSymLinks
#Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#9090,Test2
<VirtualHost *:9090>
DocumentRoot /opt/test2
DocumentRoot "/opt/test2"
<Directory "/opt/test2">
Options Indexes FollowSymLinks
#Options FollowSymLinks
#Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
cat /opt/test1/.htaccess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。