Frage

I have the following in my .conf file:

server {
        listen          80;
        server_name     mydomain.net;
        access_log      /var/log/nginx/mydomain.net.access.log  main;
        location        / {
                proxy_pass http://127.0.0.1:9000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade \$http_upgrade;
                proxy_set_header Connection "upgrade";
        }
}

Which works just fine... except everything that hits the server is getting fed to this server block. My IP, another domain pointing at this block, and the actual mydomain.net all point to what only mydomain.net is pointing to.

War es hilfreich?

Lösung

As the documentation states:

In this configuration nginx tests only the request’s header field “Host” to determine which server the request should be routed to. If its value does not match any server name, or the request does not contain this header field at all, then nginx will route the request to the default server for this port. In the configuration above, the default server is the first one — which is nginx’s standard default behaviour.

This was the case here. I performed the suggested step to drop undefined hosts:

server {
    listen      80 default_server;
    server_name "";
    return      444;
}

Which solved my issue.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top