我有一個運行在http上的應用程序,然後我試圖通過https創建登錄頁面。早期的apache web服務器用於通過ajp協議將請求轉發給作爲註冊工作者的tomcat。現在我在/etc/apache2/crt
中添加了一個密鑰和證書,即ssl.key
,ssl.crt
。那裏還有一個certificate.csr
文件。用於上述證書生成的命令是從http://www.akadia.com/services/ssh_test_certificate.html我還沒有完成第6步,因爲在/etc/apache2/sites-available
有兩個文件:default
和default-ssl
。我換了兩行default-ssl
:Apache WebServer + Tomcat + Spring + https
SSLCertificateFile /etc/apache2/crt/certificate.csr
SSLCertificateKeyFile /etc/apache2/crt/ssl.key
我也改變的tomcat server.xml
在崗位8446接收的https:
<Connector port="8446" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/etc/apache2/crt/ssl"
keystorePass="password"/>
我也改變web.xml
,現在還包含:
<security-constraint>
<web-resource-collection>
<web-resource-name>Secure Login</web-resource-name>
<url-pattern>/login/*</url-pattern>
<!-- <url-pattern>/other/secure/stuff/*</url-pattern> -->
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
我試過curl -Iv https://localhost
和curl -Iv https://localhost:8446
但出現以下錯誤:
About to connect() to localhost port 8446 (#0)
* Trying 127.0.0.1... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
請讓我知道如何做到這一點。
部分解決的答案:sudo a2ensite default-ssl並使用ssl.crt現在Apache正在443端口收聽。我希望它將其轉發給tomcat ...嘗試它.. – singhsumit 2012-07-31 11:23:07