nginx配置https方法

首先你需要在本地生产ssl的两个文件,一个KEY文件,一个SRT文件,


把这两个文件,发送到linux,nginx根目录下的conf文件里面

在nginx.conf 的server里做如下配置

server {
    listen       443 ssl;
    server_name  localhost;
    root /opt/quote_pub/menghuang/MgementPlantForm;

    ssl on;
    ssl_certificate /usr/local/nginx--with-http_stub_status_module/conf/server.crt;
    ssl_certificate_key /usr/local/nginx--with-http_stub_status_module/conf/server.key;
    error_page 497  https://$host$uri?$args;

    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    location /
     {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://192.168.0.86:9200;
    }
}

把两个文件的url加入到

ssl_certificate 

ssl_certificate_key 

这两个字段里

然后注意把防火墙毙了

service iptables stop

或者一劳永逸

chkconfig iptables off

然后网站大概就能访问https了,上面是我的配置,大家根据自己的项目更改


猜你喜欢

转载自blog.csdn.net/u014368609/article/details/54633064
今日推荐