Skip to Content
Nginx HTTP Server - Fourth Edition
book

Nginx HTTP Server - Fourth Edition

by Martin Bjerretoft Fjordvald, Nedelcu
February 2018
Beginner to intermediate
348 pages
9h 40m
English
Packt Publishing
Content preview from Nginx HTTP Server - Fourth Edition

server_name

Context: server

Assigns one or more hostnames to the server block. When Nginx receives an HTTP request, it matches the Host header of the request against all of the server blocks. The first server block to match this hostname is selected.

If no server block matches the desired host, Nginx selects the first server block that matches the parameters of the listen directive (for example, listen *:80 would be a catch-all for all requests received on port 80), giving priority to the first block that has the default_server option enabled on the listen directive.

This directive accepts wildcards as well as regular expressions. In this case, the hostname should start with the ~ character.

Syntax: server_name hostname1 [hostname2...];

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Nginx: From Beginner to Pro

Nginx: From Beginner to Pro

Rahul Soni
Nginx Essentials

Nginx Essentials

Valery Kholodkov, Valery I Kholodkov
SSH, The Secure Shell: The Definitive Guide, 2nd Edition

SSH, The Secure Shell: The Definitive Guide, 2nd Edition

Daniel J. Barrett, Richard E. Silverman, Robert G. Byrnes

Publisher Resources

ISBN: 9781788623551Other