nginx Virtual host
Good configuration nginx after Browser input IP Address can be opened nginx The welcome page
If you can't open it, it may be a firewall problem , You can turn off the firewall , Or add rules
Add virtual host
edit nginx Configuration file for
At this time, the virtual host address added to the web page cannot be accessed , You need to add the assignment to hosts
Linux Let's designate hosts
windows Let's designate hosts
Now Web search virtual machine host address and IP The address is accessible
These are the default virtual hosts
Default virtual host
vim /etc/nginx/conf.d/
In the first place is the default virtual host , By default, the first one is accessed ,
It can also be set manually , For example, copy a host file
cp default.conf 123.conf
There are only two virtual hosts below , When accessing, the default access is the first 123.conf
vim default.conf
Edit the file in 80 Add later default_server
As shown in the figure below , At this time, when visiting , It will not access the first place by default 123.conf
, It's about visiting this default.conf
The default host for
vim 123.conf
Modify according to the following figure When the changes are complete Don't forget to use nginx -t
Check to see if you can change the error , then nginx -s reload
Reload profile
Then visit... At this time www.ccc.com
You can access 123456
The content of
Pan analysis
In order to restrict other domain names from being resolved to their own servers , For example, your domain name is abc.cn
:
Make one *.abc.cn
The secondary domain name of A The record points to 222.222.222.222
, Then it takes effect when the visitor enters “123.abc.cn”
still “123.123.abc.cn”
It could even be “ [[email protected]#.$%$.6543.ww.a.abc.cn](http://oapage.xmisp.com/help/#.$%$.6543.ww.a.abc.cn) ”
Such arbitrary characters , Can point to 222.222.222.222
This IP Address . At this time, you need to disable the default virtual host
Add a line to the configuration file As shown in the figure deny all
then nginx -s reload Reload profile
At this point, accessing the default virtual host address again 403 No access .
版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/174/202206231833088460.html