I saw example configurations of nginx, most of them use example.com as a server_name and uwsgi_pass similar to unix:/var/www/run/blog.sock; or in combination with ip/port address. but what should I use in case of amazon ec2 instance, since it has long public name, ip is private and if I restart my instance it gets different public name and ip. I need shutdown instances sometime. I want to configure it for using uwsgi+django, but I am totally beginner in web area and servers.

1 Answer
1

The server_name directive is useful in cases where you want to host different sites on the same server, and handling them differently depending on the "Host" header field (ex: mysite1.com => a PHP website, mysite2.com => a django website,...)
It's actually a virtual server (see also [the server directive])1.

[...] nginx tests only the request’s header field
“Host” [against the server_name directive] 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.

If I understood, you don't want that. So you can use the underscore character (in the Miscellaneous Names section).

When I don't need to handle specific domains, I generally use "localhost". To be honest I couldn't find any explanation on what it does. I just found examples with this value, and it seems to work exactly as the underscore character.