Quantcast
Channel: Nginx: What is causing this 301 redirect? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Nginx: What is causing this 301 redirect?

$
0
0

I still don't know why my webpage is showing

myapp.com redirected you too many times.

Nginx is only used as a proxy for my django channels application, which is running with daphne.

Nginx is running with no errors.

myapp systemd[1]: Starting A high performance web server and a reverse proxy server...

Daphne is running on 127.0.0.1:8001

curl -I http://myapp.com/
curl -I https://myapp.com/

returns

HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 05 Mar 2019 11:53:39 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Location: https://myapp.com/

HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3 (Ubuntu)
Date: Tue, 05 Mar 2019 11:54:43 GMT
Content-Type: text/html
Content-Length: 194
Location: https://myapp.com/
Connection: keep-alive

Does anyone know what is causing this 301 error?

Nginx config file

server {
listen 80;
servername myapp.com www.myapp.com;
servertokens off;
return 301 https://$servername$requesturi;
}

server {
listen 443 ssl; # managed by Certbot
server_name myapp.com www.myapp.com;

ssl_certificate /etc/letsencrypt/live/myapp.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myapp.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot  

root /home/me/myapp/src/myapp;

location = /favicon.ico { access_log off; log_not_found off; }

location /static/ {
    root /home/me/myapp/src/myapp;
}

location /media/  {
    root /home/me/myapp/src/myapp;
}

location / {
    try_files $uri/ @python_django;
}

location @python_django {
    proxy_pass http://127.0.0.1:8001;
    proxy_pass_request_headers on;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;
}
}

Viewing all articles
Browse latest Browse all 2

Latest Images





Latest Images