0

我有一个使用Waitress作为服务器运行的 Django Web 应用程序。服务器的防火墙设置为允许 HTTPS 入站流量。

但是,使用下面描述的设置,我无法访问服务器本身之外的 HTTPS 站点。昨天我没有问题访问 HTTP 站点就好了。此问题仅在我包含 HTTPS 设置后发生。

我错过了什么吗?

项目settings.py包括

## SSL 
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

我的项目配置文件包括

# Redirect all non-encrypted to encrypted
server {
    listen 80 default_server;
    server_name mysite.net; # substitute your machine's IP address or FQDN
    return 301 https://$server_name$request_uri;
}

server {
    server_name mysite.net;

    listen 443 ssl;  # <-

    ssl_certificate     C:/nginx-1.17.10/ssl/mysite_net.crt;
    ssl_certificate_key     C:/nginx-1.17.10/ssl/mysite_net.key;

    access_log C:/nginx-1.17.10/logs/access.log;
    error_log C:/nginx-1.17.10/logs/error.log;


    location /static {
        alias C:/Users/batch_job/project/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        proxy_pass mysite.net:8001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;  # <-
        proxy_set_header Host $http_host;
        proxy_redirect off;


    }
}
4

0 回答 0