Difference between revisions of "Create default website in nginx"

From DevOps Notebook
(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...")
(No difference)

Revision as of 19:04, 8 October 2020

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
   }

}