0

I have a running website on a VPS but I am unable to send mail. If I look in the supervisor logs I see the following error:

Traceback (most recent call last):
  File "/home/founders/founders/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/founders/founders/lib/python3.10/site-packages/django/utils/deprecation.py", line 133, in __call__
    response = self.process_request(request)
  File "/home/founders/founders/lib/python3.10/site-packages/django/middleware/common.py", line 48, in process_request
    host = request.get_host()
  File "/home/founders/founders/lib/python3.10/site-packages/django/http/request.py", line 150, in get_host
    raise DisallowedHost(msg)
django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'founders_app_server'. The domain name provided is not valid according to RFC 1034/1035.
Bad Request: /favicon.ico

Here is my nginx configuration:

upstream founders_app_server {
        server unix:/home/founders/founders/run/gunicorn.sock fail_timeout=0;
}

server {
        listen 80 default_server;
        server_name founderslooking.com;

        client_max_body_size 4G;

        location / {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_set_header Host $http_host;

                proxy_redirect off;

                if (!-f $request_filename) {
                        proxy_pass http://founders_app_server;
                }

                # auth_basic "Testing";
                # auth_basic_user_file /home/founders/founders/.htpasswd;
        }
        location /static/ {
                autoindex on;
                root /home/founders/founders/back;
        }
        location /app/ {
                alias /home/founders/founders/dist/;
                try_files $uri $uri/ /app/index.html;
        }
        location /app/static/ {
                alias /home/founders/founders/dist/static/;
        }
}

How do I fix this please?

1
  • Invalid HTTP_HOST header error is not about mail at all. And it's a very strange way to hook Django, with if. I believe that is the problem. Can you swap location blocks, put location / to be last one, and remove if ... garbage (see here as an example)? Commented Jun 5 at 5:10

0

You must log in to answer this question.

Browse other questions tagged .