
Ich habe eine Website, bei der alle Anfragen mit HTTPS erfolgen sollen, mit Ausnahme von Anfragen an URLs mit Pfaden, die mit /out/ beginnen.
nginx ist als Proxy konfiguriert, um Gunicorn/Django-Inhalte bereitzustellen vonhttp://127.0.0.1:8000.
hier ist die Konfiguration, die ich bisher habe, aber es scheint, dass nirgendwo SSL verwendet wird.
server {
listen 80;
listen 443 default ssl;
server_name my.website.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
root /home/ubuntu/app;
client_max_body_size 1m;
access_log /home/ubuntu/app/logs/access.log;
error_log /home/ubuntu/app/logs/error.log;
location ~ ^/(out|out/.*)$ {
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:8000;
break;
}
}
location / {
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:8000;
break;
}
if ($ssl_protocol = "") {
rewrite ^ https://$server_name$request_uri? permanent;
}
}
}