关于tomcat+nginx实现登录页https访问登录转向http页面
时间:2014-10-28 11:54来源:linux.it.net.cn 作者:it
最近,由于项目要实现登录和注册页面使用https方式访问,其他页面用http方式访问,环境是tomcat+nginx,于是了解关于nginx的相关配置,我目前做的大致两步(目前有测试证书):1.配置tomcat增加<Connector>支持SSL并配置web.xml使访问登录页自动切换为https访问;2.配置nginx反向代理(但存在问题),主要问题是怎么实现https登录后转向切换到http如何转向或配置,请各位给提供个解决办法,谢谢!
我的配置如下:
tomcat server.xml配置:
-
<Connector port="8080" protocol="HTTP/1.1"
-
connectionTimeout="20000"
-
redirectPort="443" />
-
-
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
-
SSLEnabled="true" maxThreads="150"
-
scheme="https" secure="true" disableUploadTimeout="true"
-
enableLookups="false" acceptCount="100" clientAuth="false"
-
SSLCertificateFile="../conf/server.cer"
-
SSLCertificateKeyFile="../conf/server.key"
-
SSLCertificateChainFile="../conf/intermediate1.cer"
-
SSLVerifyClient="none" sslProtocol="TLS" />
nginx.conf配置:
-
server {
-
listen 80;
-
server_name localhost:8080;
-
-
#charset koi8-r;
-
-
#access_log logs/host.access.log main;
-
-
location / {
-
root yddweb;
-
#index index.html index.htm;
-
proxy_pass http://localhost:8080;
-
proxy_set_header Host $host:80;
-
proxy_set_header X-Real-IP $remote_addr;
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
proxy_set_header Via "nginx";
-
}
-
-
# HTTPS server
-
#
-
server {
-
listen 443;
-
server_name localhost:8443;
-
-
ssl on;
-
ssl_certificate server.cer;
-
ssl_certificate_key server.key;
-
-
ssl_session_timeout 5m;
-
-
#ssl_protocols SSLv2 SSLv3 TLSv1;
-
#ssl_ciphers HIGH:!aNULL:!MD5;
-
#ssl_prefer_server_ciphers on;
-
-
location / {
-
root yddweb;
-
#index index.html index.htm;
-
proxy_pass https://localhost:8443;
-
proxy_set_header Host $host:443;
-
proxy_set_header X-Real-IP $remote_addr;
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
proxy_set_header Via "nginx";
-
}
-
}
(责任编辑:IT) |
------分隔线----------------------------