Nginx: set the server_name as wildcard without hostname

Simple trick to run the nginx with no server_name.

server {
  listen 80 default_server;
  server_name _;
  location / {
    root /path/to/app;
    index index.php;
    try_files $uri $uri/ /index.php?q=$uri&$args;
    location ~* \.php {
      try_files $uri =404;
      include fastcgi_params;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_pass 127.0.0.1:9000;
    }
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *