原來我用vertx建立了一個https apiserver,想着用nginx反向代理一下。證書是阿里雲上免費一年的。html
後來發現nginx要反向代理https本身也必須是https。這樣我索性把vertx的ssl去掉了。直接用nginx的。java
個人nginx的配置文件在/etc/nginx,能夠用whereis nginx查看。nginx
從阿里雲下載證書for nginxcentos
1.在目錄下建立cert目錄,而且將下載的所有文件拷貝到cert目錄中。
2.修改配置文件api
- 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 查看是否正確session
4.若是是centos 7的話能夠systemctl restart nginx 重啓nginxapp