admin
不忘初心,方得始终
级别: 管理员
只看楼主 | | | 0楼 发表于:2018-01-11 15:19

Nginx 反向代理https网站

Nginx反向代理HTTPS网站的方法:
1.生成证书:
  #openssl genrsa -des3 -out console.eayun.cn.key 1024
  #openssl req -new -key console.eayun.cn.key -out console.eayun.cn.csr
  #cp -p console.eayun.cn.key{,.bak}
  #openssl rsa -in console.eayun.cn.key.bak  -out console.eayun.cn.key
  #openssl req -new -x509 -days 3650 -key console.eayun.cn.key -out console.eayun.cn.crt
  2.Nginx中修改证书配置:
  #vim /etc/nginx/nginx.conf:
  server {
    listen 443 ssl;
    server_name console.eayun.cn;
        ssl on;
    ssl_certificate ssl/console.eayun.cn.crt;
        ssl_certificate_key ssl/console.eayun.cn.key;
       location / {
        proxy_redirect off;
        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_send_timeout 180s;
        proxy_read_timeout 180s;
        proxy_pass https://web_https;
         expires 1d;
           }
    location = /50x.html {
        root html;
       }
}
  3.通过浏览器访问https://IP地址。