【问题标题】:Deny access include file not working in nginx conf拒绝访问包含文件在 nginx conf 中不起作用
【发布时间】:2019-05-26 13:55:16
【问题描述】:

包括不考虑拒绝访问某些ip

Nginx 1.12 被配置为代理。

我有 2 个配置文件:

nginx.conf
mydomain.conf

我按照教程获得了一个拒绝 ip 列表的列表,所有这些都在一个名为 blockips.conf 的第三个 conf 文件中。 该conf文件中的每一行都是这样的:

deny xxx.xxx.xxx.xxx;

现在,我尝试在 nginx.conf 和 mydomain.conf 文件的 http 或 server 部分中包含这样的内容(不是同时,而是先行,然后是 2n),但要么它不阻塞要么崩溃。

include blockips.conf;

但是当我只放了

deny xxx.xxx.xxx.xxx; 

直接在服务器部分的 mydomain.conf 中,然后 ip 被阻止。当然,我可以将所有 ips 列表放在 mydomain.conf 文件中,但是将其放在外部是否有意义?但它不起作用。当然,我试图让我的 blockips.conf 文件只有一行(只是为了确保它不是 ; 丢失)。

我已经检查了正确的文件,它们在根目录下都是相同的 644

谢谢

【问题讨论】:

  • 错误日志中的错误信息是什么或使用nginx -t

标签: nginx nginx-config jwilder-nginx-proxy


【解决方案1】:

我的系统上有 2 个 nginx.conf 文件,但我没有修改正确的文件! 只需执行nginx -t 即可验证正确的文件在哪里。

现在它正在工作。

【讨论】:

    猜你喜欢
    • 2012-11-19
    • 1970-01-01
    • 1970-01-01
    • 2014-06-16
    • 2017-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多