A server block groups the configuration for a website. Nginx uses the receiving address and port, then the requested host name, to choose the appropriate HTTP website.
Two domains, one server
Place these blocks inside http. Assume both domains point to the same machine:
server {
listen 80 default_server;
server_name shop.example.com;
return 200 "shop";
}
server {
listen 80;
server_name docs.example.com;
return 200 "docs";
}
A request with receives . One with receives . The Host header tells Nginx which domain the visitor requested.
