
/out/으로 시작하는 경로가 있는 URL에 대한 요청을 제외하고 모든 요청을 HTTPS로 수행하려는 웹 사이트가 있습니다.
nginx는 gunicorn/django 콘텐츠를 제공하기 위해 프록시로 구성됩니다.http://127.0.0.1:8000.
여기에 내가 지금까지 가지고 있는 구성이 있지만 SSL을 어디에도 사용하지 않는 것 같습니다.
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;
}
}
}