Config static IP address for local web development in nginx

0
2997
nginx HTTP Web Server
nginx HTTP Web Server

Often, nginx is used to serve websites for public via domain names, which is configurable via server_name option in config file. What if you want to serve for local development?

Very simple, you can omit server_name option, or provide static IP address for it. So the config will be something like following:


server {
    listen 8080;
    server_name 192.168.0.2;
    root /var/www/html;

    location / {
        try_files $uri $uri/ =404;
    }
}

You can just omit server_name if necessary.