skip to Main Content

Working perfect when accessed through local web server IP but throws 400 error when accessed through NOIP hostname.

For context, router is configured to forward requests to the web server on that port.

This is the nginx config file:

server {
    listen 80;
    server_name 192.168.1.64;
    #server_name example.ddns.net;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/projectdir;
    }

    location / {
       include proxy_params;
      # proxy_pass http://example.ddns.net;
       proxy_pass http://unix:/run/gunicorn.sock;
    }
}

I tried adding the lines where the hashtags are but to no avail.

2

Answers


  1. Chosen as BEST ANSWER

    For future reference, in my case, although I had ALLOWED_HOSTS configured correctly, the problem was reloading gunicorn/nginx after making changes to the django settings file. The following line solved it:

    sudo systemctl restart gunicorn
    sudo systemctl restart nginx
    

    Credit where it's due, comments from Iain Shelvington and Gaƫtan GR were spot on, the underlying problem was ALLOWED_HOSTS setting (which in my case was not applied until a gunicorn/nginx restart was done.


  2. Assuming your server is properly configured, edit your setting.py in your Django project with the following:

    ALLOWED_HOSTS = ["192.168.1.64"]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search