Reputation: 4136
I have the following default configuration file in nginx:
server {
listen 80;
root /home/d/www;
index index.php index.html index.htm;
server_name localhost;
Recently I added a file to host a specific domain, like:
server {
listen 80;
root /home/d/sites/dom
index index.html index.htm;
server_name dom.co www.dom.co;
After adding this, when loading the public server IP would be routed to this domain configuration folder, /home/d/sites/dom
How can the IP be directed to the default root?
Upvotes: 1
Views: 583
Reputation: 4136
To add to Vasfed's answer, my block are:
/etc/nginx/sites-available/yourdomain
server {
listen 80;
root /www/sites/**yourdomain**;
index index.html index.htm;
server_name **yourdomain**.com www.**yourdomain**.com;
}
/etc/nginx/sites-available/default
server {
listen 80 default_server;
root /www;
index index.php index.html index.htm;
server_name _;
}
Upvotes: 0
Reputation: 18454
There's listen 80 default;
for requests without Host
header (if none set - the first one is used)
For requests with unrecognized host - special server_name _;
matches
Upvotes: 2