flask nginx转发代理配置https证书请求
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>