nginx配置https同时http请求转发到https上

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;


    sendfile        on;

    keepalive_timeout  65;
    gzip  on;
    upstream www.yuyufeng.top {  
        server 127.0.0.1:8180;  
        #server 127.0.0.1:8280;  
    }

     server {
        listen 443 default ssl;  
        server_name  www.yuyufeng.top;

        #ssl on;  
        ssl_certificate      /usr/local/nginx/cert/214319706960205.pem;
        ssl_certificate_key  /usr/local/nginx/cert/214319706960205.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

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

        location / {
            #root   html;
            #index  index.html index.htm;
            proxy_pass http://www.yuyufeng.top;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

    server {
        listen       80;
        server_name  www.yuyufeng.top;
        rewrite ^(.*)$ https://www.yuyufeng.top permanent;
        location / {
            #root   html;
            #index  index.html index.htm;
            proxy_pass http://www.yuyufeng.top;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }



}
文章来源: nginx配置https同时http请求转发到https上

人吐槽 人点赞

猜你喜欢

发表评论

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:nginx配置https同时http请求转发到https上