jeudi 25 juillet 2019

When accessing a resource on website a forward slash gets removed from url when redirecting to https

I have an Nginx serving my django application. When I try to access example.com/resource it should redirect to https://example.com/resource but in my case it redirects to https://example.comresource (removing the / before resource)

I have a very minimal Nginx configuration (as you'll see below). I don't know where to start to figure out what's wrong.

server{
    listen 443;
    listen [::]:443 ssl;

    ssl on;
    ssl_certificate /etc/ssl/example_com.crt;
    ssl_certificate_key /etc/ssl/example_com.key;

    server_name example.com;

    location / {
            include proxy_params;
            proxy_pass http://unix:/run/gunicorn.sock;
    }

    location /static/ {
            autoindex on;
            alias /home/administrator/example/collectedstatic/;
    }

    location /media {
            alias /home/administrator/example/store;
    }



}



server {
    listen 8000;
    server_name localhost;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
            autoindex on;
            alias /home/administrator/example/collectedstatic/;
    }

    location /media {
            alias /home/administrator/example/store;
    }

    location / {
            include proxy_params;
            proxy_pass http://unix:/run/gunicorn.sock;
    }

}

There are no error messages, just a webpage not found.




Aucun commentaire:

Enregistrer un commentaire