Create default website in nginx

From DevOps Notebook
Revision as of 19:04, 8 October 2020 by MilosZ (talk | contribs) (Created page with "Default website in nginx is useful to close connection when someone tries to access to webserver via IP<br> which is shown in this example, but you can easily create redirect...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Default website in nginx is useful to close connection when someone tries to access to webserver via IP
which is shown in this example, but you can easily create redirect to real website or have custom page.

server {

   listen 80 default_server;
   server_name _; # This is invalid value which will match any host
   access_log /var/log/nginx/default.access.log;
   error_log /var/log/nginx/default.error.log;
   server_name_in_redirect off;
   root  /var/www/html;
   location ^~ / {
      return 444; # to close connection
   }

}