0

I have a Django server that has entries like ALLOWED_HOSTS = ['example.domain.com'].

In my nginx config, under sites-available, I have a bunch of sites listed, all listening on different servers like server_name example.domain.com on one file and example.second.com on another.

I also have a default file with the following:

server {
  listen 80 default_server;
  listen 443 default_server ssl;
  ssl_certificate <path to cert>;
  ssl_certificate_key <path to key>;
  return 444;
}

The keys are self signed keys generated using OpenSSL. I've added a symlink in sites-enabled to this default and other configurations. Nginx was also restarted.

I can however, still see django throwing the Invalid HTTP_HOST errors frequently. What else might I be missing?

UPDATE:

The server block which I want to be routed correctly (it's working) already has the host set:

server {
  listen 443 ssl http2;
  server_name xyz.example.com;
  location / {
    proxy_pass http://127.0.0.1:<port>;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  ssl_certificate <cert>;
  ssl_certificate_key <key>;
}
3
  • 443 is missing the ssl parameters
    – djdomi
    Commented May 27 at 19:07
  • @djdomi updated the line as listen 443 default_server ssl; and I still get the error.
    – lessness
    Commented May 28 at 3:58
  • always use nginx -t it tells you what to do
    – djdomi
    Commented May 28 at 7:01

0

You must log in to answer this question.

Browse other questions tagged .