Reputation: 413
What's the difference between url in browser and value of server_name? And if a well-known hostname is specified in server_name,what would happen? In nginx configuration file:
server {
listen 80;
server_name example.org www.example.org; // if google.com is specified, what happens?
...
}
Upvotes: 0
Views: 1031
Reputation: 146490
This is a virtual host which means, on same nginx/IP you can host multiple websites.
So adding a server_name
helps nginx to separate traffic from one website to other. So if you have two blocks
server {
listen 80;
server_name example.org www.example.org;
}
server {
listen 80;
server_name example1.org www.example2.org;
}
Now example.org
, www.example.org
would be handled by first block and request to example1.org
, www.example2.org
will be handled by second block. There are other options like using mask *.example.com
or using patterns ~^ww[\d]\.example\.com
.
You can get more details on below link
https://nginx.org/en/docs/http/server_names.html
Upvotes: 1