I am new to nginx and I don’t quite understand the terminology and configuration of the document. I would like to ask everyone here.
There is the following nginx configuration, and you want to point domain names such as my.domain.com
to the local directory /usr/www/
. I have reloaded the configuration file through nginx -s reload
and still cannot point to the directory and display it when accessing http://my.domain.com
.
server {
listen 80;
server_name my.domain.com;
index index.html index.htm;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
location / {
root /usr/www/;
}
}
Try to replace the domain name with the real corresponding IP address, but it doesn't work either.
Of course it will take effect if server_name is set to localhost.
It has been ensured that the host does not redirect the domain name. (By the way, will nginx and host conflict, or does iginx have higher priority?)
In the hosts file, set my.domain.com to 127.0.0.1, and then configure it in nginx