发新帖

[Nginx] Nginx相关配置

零下一度 2023-5-5 647


#防爬虫配置

if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot")
{
  return 403;
}

#指定客户端IP访问配置

server {
    listen 80;
    server_name example.com;
    root /var/www/example.com;
    index index.html;
    # 只允许IP为192.168.1.100的客户端访问
    location / {
        allow 192.168.1.100;
        deny all;
        # 其他配置项
    }
}


#转到的Nginx文件目录

alias /xxx/files;

#打开目录浏览功能

autoindex on;

#默认为on,显示出文件的确切大小,单位是bytes

#显示出文件的大概大小,单位是kB或者MB或者GB

autoindex_exact_size off;

#默认为off,显示的文件时间为GMT时间。

#改为on后,显示的文件时间为文件的服务器时间

autoindex_localtime on;

#让浏览器不保存临时文件

add_header Cache-Control no-store;

#避免中文乱码

charset utf-8,gbk;

#希望请求文件是下载而不是显示内容

#add_header Content-Disposition attachment;



最新回复 (0)
返回
零下一度
主题数
931
帖子数
0
注册排名
1