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

私のプロジェクトのconfファイルには

# 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