全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
楼主: 奧巴马

分享一个nginx安全规则。

  [复制链接]
发表于 2022-7-10 21:22:53 | 显示全部楼层
这可怕的收藏量!
发表于 2022-7-10 21:29:08 | 显示全部楼层
有没有100G的文件 我觉得10G太小了
发表于 2022-7-10 21:42:23 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2022-7-10 22:30:05 | 显示全部楼层
我是坏虫 发表于 2022-7-10 20:42
nginx: [emerg] invalid condition "$request_uri" in /www/server/panel/vhost/nginx/bbs.latinese.net. ...


我保存成功了
发表于 2022-7-10 22:57:22 | 显示全部楼层
感谢大佬,学到了。。。。
祝大佬夜夜换新娘。
发表于 2022-7-10 22:59:12 | 显示全部楼层
  1. ERROR:
  2. nginx: [emerg] "if" directive is not allowed here in /www/server/nginx/conf/nginx.conf:112
  3. nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
复制代码
 楼主| 发表于 2022-7-10 23:04:53 | 显示全部楼层

不能放到
location 里面
发表于 2022-7-10 23:12:41 | 显示全部楼层
奧巴马 发表于 2022-7-10 23:04
不能放到
location 里面

没放在location里面呀,放在nginx最后面
 楼主| 发表于 2022-7-10 23:17:24 | 显示全部楼层
yanyuo 发表于 2022-7-10 23:12
没放在location里面呀,放在nginx最后面


示例:

  1. server {
  2.         listen        80;
  3.         server_name  localhost;
  4.         root   "D:/phpstudy_pro/WWW";
  5.         location / {
  6.             index index.php index.html;
  7.             error_page 400 /error/400.html;
  8.             error_page 403 /error/403.html;
  9.             error_page 404 /error/404.html;
  10.             error_page 500 /error/500.html;
  11.             error_page 501 /error/501.html;
  12.             error_page 502 /error/502.html;
  13.             error_page 503 /error/503.html;
  14.             error_page 504 /error/504.html;
  15.             error_page 505 /error/505.html;
  16.             error_page 506 /error/506.html;
  17.             error_page 507 /error/507.html;
  18.             error_page 509 /error/509.html;
  19.             error_page 510 /error/510.html;
  20.             autoindex  off;
  21.         }

  22.         if ($request_uri ~* "(\.gz)|(\")|(\.tar)|(admin)|(\.zip)|(\.sql)|(\.asp)|(\.rar)|(function)|($_GET)|(eval)|(\?php)|(config)|(\')|(\.bak)") {
  23.             return 301 http://lg-dene.fdcservers.net/10GBtest.zip;
  24.         }
  25.         location ~ \.php(.*)$ {
  26.             fastcgi_pass   127.0.0.1:9000;
  27.             fastcgi_index  index.php;
  28.             fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
  29.             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  30.             fastcgi_param  PATH_INFO  $fastcgi_path_info;
  31.             fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
  32.             include        fastcgi_params;
  33.         }
  34. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-27 11:56 , Processed in 0.065329 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表