Nginx default catch all configuration

nginx

We are using nginx to serve static content and apache for dynamic content.

I have defined a default server configuration as:

#Set a default server that simply proxies all requests to apache
server 
{
    listen 80 default_server;
    server_name _;

    location / 
    {
        proxy_pass http://127.0.0.1:8080;
    }
}

Is the the best way to proxy everything to apache if for some reason a server_name does not match?

Best Answer

Yes this is the best and the only sensible way. You could even omit the servername completely.