我在RHEL 6中安装了apache,一切都很好。要使用https://localhost:443/,应该做哪些更改和配置。
如果我将“List80”更改为443,则会引发SSL连接错误。
错误107 (net::ERR_SSL_PROTOCOL_ERROR):SSL协议错误。
发布于 2012-04-18 17:48:14
不要将Listen 80更改为443 in /etc/httpd/conf/httpd.conf。SSL是在/etc/httpd/conf.d/ssl.conf中配置的。在RHEL 6上,启用SSL并默认使用自签名证书进行侦听。
您只需浏览到https://localhost就可以使用SSL访问默认站点(您不需要将端口添加到URL的末尾)。
如果您想将所有HTTP请求转发到HTTPS (我认为您正在努力实现这一点),您可以添加永久重定向,或者使用Apache模块mod_rewrite。
最简单和最安全的方法是建立一个永久的重定向。启用命名的虚拟主机,并将Redirect指令添加到/etc/httpd/conf/httpd.conf中的VirtualHost中。
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
Redirect permanent / https://localhost
</VirtualHost>使用mod_rewrite,您还可以创建一个命名的虚拟主机。这不是推荐的方法,但会有效的。
NameVirtualHost *:80
<VirtualHost *:80>
# Enable the Rewrite engine
RewriteEngine On
# Make sure the connection is not already HTTPS
RewriteCond %{HTTPS} !=on
# This rewrites the URL and forwards to https
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>如果您想关闭SSL,请在/etc/httpd/conf.d/ssl.conf中注释掉这些行并重新启动Apache。
LoadModule ssl_module modules/mod_ssl.so
Listen 443https://unix.stackexchange.com/questions/36786
复制相似问题