Nginx Server

In the configuration syntax for nginx(8), a server is a fully qualified domain and the corresponding configurations for serving that website.


Usage

A server listens on one or more addresses and ports, specified on the listen directive. If the address is left off, nginx(8) listens on all addresses for that server. Servers can share addresses and/or ports.

When a request is received, it is routed between the listening servers based on the domain name. Each server is meant to represent a single web domain, which should be specified on the server_name directive. If a server needs to respond as any domain, enter _ as the name.

If no server name matches, the request is routed to the default server, which is marked by the default_server option on the listen directive. nginx(8) requires one (and only one) server be marked as default.

Typically, the default server is configured with a server name of _ and returns error 444 to all requests.

server {
  listen 80 default_server;
  server_name _;
  return 444;
}

server {
  listen 80;
  server_name example.com;

  root /var/www;

  location / {
    try_files $uri $uri/ /index.html;
  }
}


CategoryRicottone

Nginx/Server (last edited 2023-04-22 20:40:35 by DominicRicottone)