私のdjangoアプリケーションを実行するには、ローカルの私のgunicorn djangoサーバーにリバースプロキシを使用しています。nginx rewriteはリダイレクトループにつながります
サイトがhttpsアクセスのみを目的としているため、SSL要求を強制的に送信しようとしています。アプリケーションは、ポート8888(80と443の撮影)だけを聞くので、8888ポートが指定されている場合にのみサイトにアクセスできるようにする必要があります。
サーバーブロックとロケーションブロックのrewrite^https://domain.net:8888$request_uri? permanent;
で書き直そうとしました。 HTTP要求を同じURLにリダイレクトしないだけでなく、https要求があるときにリダイレクトループも発生します。
server {
listen 8888;
server_name sy-system.net;
rewrite^https://domain.net:8888$request_uri? permanent;
ssl on;
ssl_certificate /path/to/domain.pem;
ssl_certificate_key /path/to/domain.key;
# serve directly - analogous for static/staticfiles
location /media/ {
root /path/to/root;
}
location /static/ {
root /path/to/root;
}
location/{
#rewrite^https://sy-system.net:8888$request_uri? permanent;
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://127.0.0.1:8881/;
proxy_set_header X-Forwarded-Protocol https;
}
# what to serve if upstream is not available or crashes
error_page 500 502 503 504 /media/50x.html;
}
ちょうどよく分かった、ありがとう – zentenk