Nginx防止直接用IP访问Web服务器设置方法
看了很😩多Nginx的配置【de pèi zhì】,好像都💕忽略了🈳ip直接访问Web的问题🏭,这样理😬论上不利于SEO优化🏉,所以我【suǒ yǐ wǒ】📎们希望【men xī wàng】可以避免直接【miǎn zhí jiē】用⛪IP访问网站【zhàn】,而是域【ér shì yù】名访问【míng fǎng wèn】,具体怎么做呢,看下面【kàn xià miàn】。
官方文档中提供的方法:
If you do not want to process requests with undefined "Host" header lines, you may define a default server that just drops the requests:
server
server
server
location /
}
这样就实现了我们想要的功能了。
关键词:Nginx,Web服务器
阅读本文后您有什么感想? 已有 人给出评价!
- 0
- 0
- 0
- 0
- 0
- 0