HTTP directives

server_name directive (HTTP)

Declares names used in HTTP virtual-server selection. Context: server. The default name is an empty string. The first declared name is the primary name. This directive neither creates DNS records nor selects the default server for a listener. Example is a partial configuration for the supplied isolated lab; do not paste it into a running host configuration.

Formal Syntax & Structure

nginx syntaxnginx
server_name name ...;

Parameters & Attributes

NameTypeDescription
namestringOne or more exact names, or supported wildcard/regex patterns.

Working Example

Example Snippetnginx
server {    listen 127.0.0.1:18080;    server_name localhost;    root html;}
Nginx Reference