I am getting Invalid HTTP_HOST header error on my server. I don't understand why it's happening and how to fix it. Everytime it happens backend stops working and I have to restart the server.
Any help will be appreciated.
Thanks in advance!
FYI : Server is aws ec2; frontend is angular and backend is django/drf with gunicorn. Angular and DRF are both deployed on the same server.
Error 0. If I don't set the Host variable in nginx.conf, I get below error many times. Invalid HTTP_HOST header: '/run/gunicorn.sock:'. The domain name provided is not valid according to RFC 1034/1035.
If I set the Host variable in nginx.conf, I get below errors.
Error 1. proxy_set_header Host $http_host;
Invalid HTTP_HOST header: '127.0.0.1:8000,127.0.0.1:8000'. The domain name provided is not valid according to RFC 1034/1035.
Error 2. proxy_set_header Host $host;
Invalid HTTP_HOST header: '127.0.0.1:8000,127.0.0.1'. The domain name provided is not valid according to RFC 1034/1035.
Error 3. proxy_set_header Host $server_name;
Invalid HTTP_HOST header: '13.234.187.18,13.234.187.18:8000'. The domain name provided is not valid according to RFC 1034/1035.
nginx.conf is as below.
server {
listen 8000;
server_name 13.234.187.18;
location / {
proxy_set_header Host $host;
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
I found below code on the nginx website. Will it solve this problem? http://nginx.org/en/docs/http/request_processing.html
server {
listen 80;
server_name "";
return 444;
}