• nginx 反向代理https


    nginx 反向代理https

    原来我用vertx创建了一个https apiserver,想着用nginx反向代理一下。证书是阿里云上免费一年的。

    后来发现nginx要反向代理https自己也必须是https。这样我索性把vertx的ssl去掉了。直接用nginx的。

    我的nginx的配置文件在/etc/nginx,可以用whereis nginx查看。

    从阿里云下载证书for nginx

    1.在目录下创建cert目录,并且将下载的全部文件拷贝到cert目录中。

    2.修改配置文件

    [java] view plain copy
     
    1. server {  
    2.       listen       443 ssl;  
    3.       server_name  www.zyyapp.com;  
    4.   ssl_certificate   cert/2146842898821.pem;  
    5.   ssl_certificate_key  cert/214684289890721.key;  
    6.   ssl_session_timeout 5m;  
    7.   ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  
    8.   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  
    9.   ssl_prefer_server_ciphers on;  
    10.   
    11.       location / {  
    12.   #        root   html;  
    13.   #        index  index.html index.htm;  
    14.   
    15.           proxy_pass  https://127.0.0.1:8080;  
    16.           ### force timeouts if one of backend is died ##  
    17.           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;  
    18.   
    19.           ### Set headers ####  
    20.           proxy_set_header Host $host;  
    21.           proxy_set_header X-Real-IP $remote_addr;  
    22.           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
    23.   
    24.           ### Most PHP, Python, Rails, Java App can use this header ###  
    25.           proxy_set_header X-Forwarded-Proto https;  
    26.   
    27.           ### By default we don't want to redirect it ####  
    28.           proxy_redirect     off;  
    29.   
    30.       }  
    31.   }  

    3.nginx -t 查看是否正确

    4.如果是centos 7的话可以systemctl restart nginx 重启nginx

  • 相关阅读:
    13.numpy线性代数和绘图
    12-numpy矩阵
    11-numpy视图与副本
    10-numpy排序搜索
    day12 异常 模块 单例
    day11面向对象 多态 静态方法 (三)
    day 10 面向对象(=)
    day9 面向对象
    day8 文件
    day7 地址 名片管理系统
  • 原文地址:https://www.cnblogs.com/lxg0/p/9094921.html
Copyright © 2020-2023  润新知