原來我用vertx創(chuàng)建了一個https apiserver,想著用nginx反向代理一下。證書是阿里云上免費一年的。
后來發(fā)現(xiàn)nginx要反向代理https自己也必須是https。這樣我索性把vertx的ssl去掉了。直接用nginx的。
我的nginx的配置文件在/etc/nginx,可以用whereis nginx查看。
從阿里云下載證書for nginx
1.在目錄下創(chuàng)建cert目錄,并且將下載的全部文件拷貝到cert目錄中。
2.修改配置文件
server {
listen 443 ssl;
server_name www.zyyapp.com;
ssl_certificate cert/2146842898821.pem;
ssl_certificate_key cert/214684289890721.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
# root html;
# index index.html index.htm;
proxy_pass https:
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
### Set headers ####
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
### Most PHP, Python, Rails, Java App can use this header ###
proxy_set_header X-Forwarded-Proto https;
### By default we don't want to redirect it ####
proxy_redirect off;
}
}
3.nginx -t 查看是否正確
4.如果是centos 7的話可以systemctl restart nginx 重啟nginx
轉(zhuǎn)自https://www.cnblogs.com/lxg0/p/9094921.html
該文章在 2025/8/7 10:42:29 編輯過