PLANET_08
2018-09-17 11:29Nginx如何实现一个域名多个端口共用一个证书?
5# http自动转https
server {
listen 80;
index index.php index.htm index.html;
server_name xxx.com www.xxx.com; #监听nginx所在服务器8080端口
return 301 https://www.xxx.com$request_uri;
}
#ssl证书配置
server {
listen 443;
server_name www.xxx.com;
ssl on;
ssl_certificate 1_xxx.com_bundle.crt;
ssl_certificate_key 2_xxx.com.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;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
#你的项目端口号
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
}
}
server {
listen 443;
server_name www.xxx.com:8081;
ssl on;
ssl_certificate 1_xxx.com_bundle.crt;
ssl_certificate_key 2_xxx.com.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;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
#你的项目端口号
proxy_pass http://127.0.0.1:8081/;
proxy_redirect off;
}
}
如上,我想要配置nginx的ssl证书,8080是我的项目,8081是tomcat图片服务器,现在8080已经有ssl证书了,但是8081没有,运这样配置nginx运行不起来,求解~有什么办法~
- 点赞
- 回答
- 收藏
- 复制链接分享
3条回答
为你推荐
- Nginx如何实现一个域名多个端口共用一个证书?
- 域名
- 服务器
- nginx
- 3个回答