码迷,mamicode.com
首页 > Web开发 > 详细

nginx 1.10 代理https 钉一钉

时间:2017-09-21 23:31:40      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:nginx openssl http https

环境:

centos6.5

nginx:1.10

openssl:1.0.1e-15


测试样例一:


web访问 https协议的URL  https://test.xx.com/demo


nginx  开启证书配置,代理后端非安全协议的url,例如:http://xx.xx.com/xx

server {

    listen 443;

    server_name test.xxxx.com;

    ssl                  on;

    ssl_certificate      /etc/nginx/key_file/xxxx.crt;

    ssl_certificate_key  /etc/nginx/key_file/xxxx.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_session_cache shared:SSL:50m;

    ssl_prefer_server_ciphers on;


    access_log /var/log/nginx/test.access.log;

    error_log /var/log/nginx/test.error.log;

    index index.html index.htm index.php index.jsp;


 location /demo{

       proxy_pass    http://x.x.x.x/demo;

       proxy_redirect off;

       client_max_body_size  8m;

       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_connect_timeout 60s;

   }

}


前端访问 https://test.xx.com/demo

这种模式在普通的后端server可以正常访问页面(数据转发之类的),但在负责多样式的页面调试会出现相关样式调用错误。



测试样例二:


web访问 https协议的URL  https://test.xx.com/demo


nginx  开启证书配置,代理后端安全协议的url,例如:https://xx.xx.com/xx

server {

    listen 443;

    server_name test.xxxx.com;

    ssl                  on;

    ssl_certificate      /etc/nginx/key_file/xxxx.crt;

    ssl_certificate_key  /etc/nginx/key_file/xxxx.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_session_cache shared:SSL:50m;

    ssl_prefer_server_ciphers on;


    access_log /var/log/nginx/test.access.log;

    error_log /var/log/nginx/test.error.log;

    index index.html index.htm index.php index.jsp;


 location /demo{

       proxy_pass    https://x.x.x.x/demo;

       proxy_redirect off;

       client_max_body_size  8m;

       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_connect_timeout 60s;

   }

}


这种模式比较消耗后端性能。

此时:后端server https://172.10.18.34:8443/mpweb访问正常,

技术分享

前端访问 https://test.xxxx.com/demo报502 错误,查访问日志

技术分享


在代理与后端server之间的ssl协议会话的时候,出现一下错误:

 [error] 7957#7957: *720292 SSL_do_handshake() failed (SSL: error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group error:1408D010:SSL routines:SSL3_GET_KEY_EXCHANGE:EC lib) while SSL handshaking to upstream, client: 技术分享x.x.x.x, server: 技术分享test.huiepay.com, request: "GET /favicon.ico HTTP/1.1", upstream: "技术分享https://172.10.18.34:8443/favicon.ico", host: "技术分享test.xxxx.com", referrer: "技术分享https://test.xxxx.com/mpweb" 


通过测试样例一可以得出,排除后端server问题,依然是代理错误。


通过elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group”根据这个报错信息判断是的 可以判断出: openssl什么版本


技术分享

升级openssl以后

技术分享

技术分享

访问正常

技术分享


总结:nginx代理ssl时候,有两种模式:


1、代理后端非ssl url

2、代理后端ssl url,此种方法一定注意openssl的版本,日志会有详细的说明,升级到最新的openssl版本再试。




本文出自 “欢迎光临wenchy博客” 博客,请务必保留此出处http://wenchylinux.blog.51cto.com/1340633/1967624

nginx 1.10 代理https 钉一钉

标签:nginx openssl http https

原文地址:http://wenchylinux.blog.51cto.com/1340633/1967624

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!