当前位置:首页 - 服务器配置

flask nginx转发代理配置https证书请求

作者:高景洋 日期:2020-12-06 01:06:25 浏览次数:2165

1、nginx 版本 : nginx-1.18.0


2、http 配置 

    server {
        listen       80;

        server_name  www.XXXX.cn; 
        if ($host = 'www.XXXX.cn' ){ # 将带www的域名301到https
           rewrite ^/(.*)$ https://www.XXXX.cn/$1 permanent;
        }

        if ($host = 'XXXX.cn' ){ # 将不带带www的域名301到https
           rewrite ^/(.*)$ https://www.XXXX.cn/$1 permanent;
        }

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass http://127.0.0.1:8080;
        #    root   html;
        #    index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

3、https配置

    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  www.XXXX.cn;

        ssl_certificate      /etc/ssl/certs/XXXX/XXXX.cn_bundle.crt;
        ssl_certificate_key  /etc/ssl/certs/XXXX/XXXX.cn.key;

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

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

        location / {
            proxy_pass http://127.0.0.1:8080;
        #    root   html;
        #    index  index.html index.htm;
        }
    }

本文永久性链接:
<a href="http://r4.com.cn/art168.aspx">flask nginx转发代理配置https证书请求</a>
当前header:Host: r4.com.cn X-Host1: r4.com.cn X-Host2: r4.com.cn X-Host3: 127.0.0.1:8080 X-Forwarded-For: 18.191.150.17 X-Real-Ip: 18.191.150.17 X-Domain: r4.com.cn X-Request: GET /art168.aspx HTTP/1.1 X-Request-Uri: /art168.aspx Connection: close Accept: */* User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) Accept-Encoding: gzip, br, zstd, deflate