项目中采用的是阿里云服务器,想换成https,需要在阿里云中去下载两个文件
1、282314911__ceshi.cn.key
2、282314911__ceshicn.pem
需要将这两个文件放在服务器上面的nginx文件的nginx.conf文件同级
下面是nginx的设置:
upstream project{
session_sticky mode=insert option=indirect;
server 127.0.0.1:1011;
check interval=3000 rise=2 fall=2 timeout=1000 type=http;
check_http_send "HEAD /jkv2.jsp HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
server {
listen 443 ssl;
server_name www.ceshi.cn;
ssl on;
ssl_certificate /opt/nginx/conf/282314911__ceshi.pem;
ssl_certificate_key /opt/nginx/conf/282314911__ceshi.cn.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location ~* \.(html|htm|shtml|zip|rar|doc|docx|xls|xlsx|ppt|ppts|gif|jpg|jpeg|png|bmp|swf|ico|js|css)$ {
root /data/ceshi;
}
location / {
proxy_set_header Host $host:80;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
session_sticky_hide_cookie upstream=web_s;
proxy_pass http://project;
}
}
然后重启nginx
/opt/nginx/sbin/nginx -t
/opt/nginx/sbin/nginx -s reload
即可生效