我有一个网站,我希望所有请求都通过 HTTPS 完成,除了以 /out/ 开头的路径的 URL 的请求。
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;
}
}
}