Reputation: 161
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.
Upvotes: 1
Views: 954
Reputation: 161
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.
Upvotes: 1
Reputation: 1398
Assuming your server is properly configured, edit your setting.py in your Django project with the following:
ALLOWED_HOSTS = ["192.168.1.64"]
Upvotes: 1