nginx without server_name and using only static ip address?

Solution 1:

server_name defaults to an empty string, which is fine; you can exclude it completely.

Another common approach for the "I don't want to put a name on this" need is to use server_name _;

Your http://xxx.xxx.xxx.xxx:9050 URL won't work with this config, though; you're only listening on port 80. You'd need to add a listen 9050; as well.

Solution 2:

server_name _; is not a wildcard see here:

http://blog.gahooa.com/2013/08/21/nginx-how-to-specify-a-default-server

just specify the default_server directive for ip-only access (see http://nginx.org/en/docs/http/request_processing.html)

server {
    listen 1.2.3.4:80 default_server;
    ... 
    }

Solution 3:

If you want your app to respond on port 9050 without specific hostname then you can just skip server_name, it's not required since Nginx first resolves listen entry and then server_name if present:

server {
   listen 9050;

   .....
}

More details here: Nginx server_name and how it works