为什么 https 不起作用?

Thi*_*key 11 mod-rewrite ssl https httpd apache-2.2

我正在尝试将我的网站的根目录重定向到 https。尽管重写发生了,但 https 不会产生任何结果。浏览器说。connecting to thinkingmonkey.me...和停滞。

  • 听 80听 443存在于 conf 文件中。
  • 我已经重新启动了 httpd。
  • 我正在使用正确的证书文件和私钥文件。
  • httpd 日志中没有错误,SSL 日志(我有一个单独的SSl 日志)。
  • 即使我尝试直接访问https://thinkingmonkey.me,实际上也没有任何内容记录到 SSL 访问日志中。

Anetstat -pant | grep httpd有这个:

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  
tcp        0      0 :::443                      :::*                        LISTEN      1334/httpd          
tcp        0      0 :::80                       :::*                        LISTEN      1334/httpd   
Run Code Online (Sandbox Code Playgroud)

.htaccess:

RewriteEngine on
RewriteBase /

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ https://thinkingmonkey.me [L,R=302]
Run Code Online (Sandbox Code Playgroud)

重写日志数据:

my-ip - - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (2) 使用请求的 uri /

my-ip初始化重写引擎- - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (1) 通过 /

my-ip - - [24/Jan/2012: 19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (3) [perdir /mysite/] 去除 per-dir 前缀:/mysite/ ->

my-ip - - [ 24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa239336d8/initial] (3) [perdir /mysite/] 应用模式 '^(.*)$' uri ''

my-ip - - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (4) [perdir /mysite/] RewriteCond: input='80' 模式='80' => 匹配

my-ip - - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (4) [perdir /mysite/] RewriteCond: input=' /' pattern='^/$' => 匹配

my-ip - - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (2 ) [perdir /mysite/] 重写 '' -> ' https://thinkingmonkey.me '

my-ip - - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18] [rid#7fa2339336d8/initial] (2) [perdir /mysite/] 明确强制重定向https://thinkingmonkey.me

my-ip - - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey. me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (1) [perdir /mysite/] 转义https://thinkingmonkey.me以进行重定向

my-ip - - [24/Jan/2012:19:01:14 +0000] [thinkingmonkey.me/sid#7fa2335ceb18][rid#7fa2339336d8/initial] (1) [perdir /mysite/] 重定向到https:// /thinkingmonkey.me [重定向/302]

这是我的虚拟主机。

<VirtualHost *:80>
     ServerName thinkingmonkey.com
     ServerAlias www.thinkingmonkey.com  www.thinkingmonkey.me

     RewriteEngine on
     RewriteCond %{HTTP_HOST} ^(www\.)?thinkingmonkey\.(com|me)$ [NC]
     RewriteRule ^ http://thinkingmonkey.me%{REQUEST_URI} [L,R=301]
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /mysite/
    ServerName thinkingmonkey.me
    ErrorLog logs/site-error_log
    CustomLog logs/site-access_log common
    RewriteEngine On
    RewriteLog "/var/log/rewrite.log"
    RewriteLogLevel 3
</VirtualHost>

<VirtualHost *:443>

ServerName thinkingmonkey.me

ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

SSLEngine on

SSLProtocol all -SSLv2

SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW


SSLCertificateFile /path/to/my.crt
SSLCertificateKeyFile /path/to/my.key
SSLCertificateChainFile /path/to/my.ca-bundle


<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>
SetEnvIf User-Agent ".*MSIE.*" \
     nokeepalive ssl-unclean-shutdown \
     downgrade-1.0 force-response-1.0

CustomLog logs/ssl_request_log \
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
lsof -i -P | grep 443
httpd    1334     root    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1335   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1336   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1337   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1338   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1339   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1340   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1341   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
httpd    1342   apache    6u  IPv6   3297      0t0  TCP *:443 (LISTEN)
Run Code Online (Sandbox Code Playgroud)

这里出了什么问题?

cjc*_*cjc 15

好的,试试这个:

telnet localhost 443
Run Code Online (Sandbox Code Playgroud)

这会给出响应,还是挂起?如果它有响应,您应该得到如下所示的内容:

$ telnet localhost 443
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Run Code Online (Sandbox Code Playgroud)

(如果未安装 telnet,则安装它;您可以通过点击control-]然后键入“q”退出来退出telnet 会话)

如果您能够在本地界面上连接到 Web 服务器(并且 Web 服务器正在运行,根据您的日志),则存在防火墙问题(我知道您说您没有设置防火墙,但这会确认)。在这种情况下,运行:

iptables -L -n
Run Code Online (Sandbox Code Playgroud)

并发布结果。

更新

根据评论,这是一个 EC2 实例,因此请查看与此实例关联的安全组。确保您在安全组中允许使用 tcp/443。

像这样的事情可能会有所帮助:

http://cloud-computing.learningtree.com/2010/09/24/understanding-amazon-ec2-security-groups-and-firewalls/