nginx配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx配置相关的知识,希望对你有一定的参考价值。

网站的搬运整理工

1、禁止盗链

相关详细配置

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico|mp4)$
{
        valid_referers none blocked *.vp.cn *.91m2m.com;
        if ($invalid_referer) {
            return 403;
            # rewrite ^/ http://www.vp.cn;
        }

2、禁止爬虫

详细1
详细2

if ($http_user_agent ~ "WinHttp|WebZIP|FetchURL|node-superagent|java/|FeedDemon|Jullo|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|Java|Feedly|Apache-HttpAsyncClient|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|HttpClient|MJ12bot|heritrix|EasouSpider|Ezooms|BOT/0.1|YandexBot|FlightDeckReports|Linguee Bot|^$" ) {
    return 403;
}

#禁止非GET|HEAD|POST方式的抓取  
if ($request_method !~ ^(GET|HEAD|POST)$) {
    return 403;
}

以上是关于nginx配置的主要内容,如果未能解决你的问题,请参考以下文章

Nginx——Nginx启动报错Job for nginx.service failed because the control process exited with error code(代码片段

Nginx配置文件详细介绍

Nginx 跨域

Nginx的配置

VSCode自定义代码片段11——vue路由的配置

VSCode自定义代码片段11——vue路由的配置