Exclude specific urls from nginx redirect
I'm trying to exclude two URLs from nginx redirect (http to https). Traffic from Nginx is sent to guincorn and the URLs are generated dynamically by the Django view.
My current base nginx configuration for the site is below. All non http requests are sent to https using this.
server {
listen 80;
listen [::]:80 default_server;
server_name mydomain.org;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate ....;
ssl_certificate_key ....;
root /app/ioc;
server_name mydomain.org;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /path/static/;
}
location / {
proxy_pass http://unix:/run/gunicorn.sock;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
}
}
Now, I'm trying to exclude both this/endpoint1.txt
and this/endpoint2.txt
from the redirects. endpoint1.txt
and endpoint1.txt
are dynamically generated by the django view so they are not actual text files on the server.
Trying to do something like this results in 404 error
location /this/endpoint1.txt {
root /path/app;
add_header Content-Type text/plain;
}
Also, when I do something like this:
location /this/endpoint1.txt {
proxy_pass http://127.0.0.1:80;
}
I get 504 Gateway Time-out error.
I'm binding gunicorn like this "0.0.0.0:8000"