配置Nginx+Tomcat的SSL
1、修改tomcat的server.xml
第一个:
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000" URIEncoding="UTF-8"
redirectPort="8443" scheme="https" proxyName="tangka.mobi" proxyPort="443" />
第二个:
<Connector port="8082" protocol="HTTP/1.1"
connectionTimeout="20000" URIEncoding="UTF-8"
redirectPort="8443" scheme="https" proxyName="tangka.mobi" proxyPort="443" />
2、修改Nginx的nginx.conf
-- 配置文件开始 --
worker_processes 1;
events {
worker_connections 1024;
}
http{
upstream alam{
ip_hash;
server tangka.mobi:8081;
server tangka.mobi:8082;
}
server{
#监听443端口
listen 443 ssl;
#对应的域名,把tangka.mobi改成你们自己的域名就可以了
server_name tangka.mobi;
#从腾讯云获取到的第一个文件的全路径
ssl_certificate /usr/local/nginx/cert/2039758_tangka.mobi.pem;
#从腾讯云获取到的第二个文件的全路径
ssl_certificate_key /usr/local/nginx/cert/2039758_tangka.mobi.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
#这是我的主页访问地址,因为使用的是静态的html网页,所以直接使用location就可以完成了。
location / {
proxy_pass http://tangka.mobi:3000;
}
location /TANG_KA {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_pass http://alam;
client_max_body_size 2000m;
}
}
server{
listen 80;
server_name tangka.mobi;
return 301 https://$host$request_uri;
}
server{
listen 8088;
server_name tangka.mobi;
location / {
proxy_pass http://tangka.mobi:8081;
}
}
}
-- 配置文件结束 --