【发布时间】:2018-11-27 17:45:07
【问题描述】:
在我的 nginx 服务器中,我会将所有 http 传入请求重定向到 https。 我使用 gunicorn 并将代理设置为 / 位置 127.0.0.1:8080 我的 nginx.conf 配置文件的一部分是:
server {
listen 80;
listen 443 default ssl http2;
ssl_certificate /var/www/web/core/mycert.crt;
ssl_certificate_key /var/www/web/core/mykey.key;
server_name ~^(?<subdomain>\w+)\.mydomain\.io$;
root /var/www;
return 301 https://$server_name$request_uri;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /static/ {
alias /var/www/web/core/frontend/static/;
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
#add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
proxy_set_header X-DTS-SCHEMA $subdomain;
}
但是当我尝试打开我的页面的 http 版本时,我得到“错误到许多重定向” 我还尝试添加我的代理指令:
proxy_redirect http:// https://;
但什么也没发生。
如何每次都将我的代理请求重定向到 https?
提前致谢
【问题讨论】: