gpt4 book ai didi

docker - 如何更正 firewalld 和 docker/nginx 的配置?

转载 作者:行者123 更新时间:2023-12-03 14:20:54 28 4
gpt4 key购买 nike

我有一个 CentOS 7 服务器,它运行了 600 多天,直到它最近重新启动,之后传入的 Web 请求收到 HTTP523(源不可访问)错误代码(通过 Cloudflare,如果这有什么不同?)除非我停止firewalld服务。没有 firewalld 一切正常,但我宁愿不要让它禁用!
我试过停止 dockerfirewalld并以各种顺序重新启动它们,但相同 523除非我停止 firewalld,否则会发生错误./var/log/firewalld包含一些可能有帮助的警告:

  • WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i br-8acb606a3b50 -o br-8acb606a3b50 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).
  • WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?).
  • WARNING: AllowZoneDrifting is enabled. This is considered a n insecure configuration option. It will be removed in a future release. Please consider disabling it now.
  • WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t nat -D PREROUTING -m addrtype --dst-type LOCAL -j DOCKER' failed: iptables v1.4.21: Couldn't load target 'DOCKER':No such file or directory
  • WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t nat -D PREROUTING' failed: iptables: Bad rule (does a matching rule exist in that chain?).
  • WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t nat -D OUTPUT' failed: iptables: Bad rule (does a matching rule exist in that chain?)
  • WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -t nat -F DOCKER' failed: iptables: No chain/target/match by that name.

  • 关于所需的任何手动配置/命令,我在该地方发现了看似相互矛盾的建议:
  • firewall-cmd --permanent --zone=trusted --add-interface=docker0 on a CentOS forum
  • firewall-cmd --zone=trusted --remove-interface=docker0 --permanent on the offical Docker docs ——这肯定与上述相反吗?
  • a bunch of manual firewall-cmd commands on a Docker github issue ——当然所有这些都不是必需的?
  • 这个看起来很有希望—— nmcli , NetworkManager and firewall-cmd --permanent --zone=trusted --change-interface=docker0

  • 我不完全明白 br-8acb606a3b50 在哪里接口(interface)来自,或者我是否需要做任何事情来配置它以及 docker0如果我使用像 4. 这样的解决方案多于?在重新启动之前,它多年来一直自动运行良好!
    有什么魔法 firewalld现在需要咒语(为什么?!)或者有什么方法可以让系统恢复到重新启动之前的正确自动/默认配置?
    $ docker -v
    Docker version 20.10.5, build 55c4c88
    $ firewall-cmd --version
    0.6.3
    $ firewall-cmd --get-zones
    block dmz docker drop external home internal public trusted work

    最佳答案

    回顾 chat investigation ,这个特殊问题与 Docker 和容器无关。问题出在 firewalld没有NGINX 的规则作为主机上容器的代理运行。解决方案是为 HTTP 和 HTTPS 流量添加永久防火墙规则:

    sudo firewall-cmd --permanent --zone=public --add-service=http
    sudo firewall-cmd --permanent --zone=public --add-service=https
    sudo firewall-cmd --reload
    像这样的警告消息:

    WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i br-8acb606a3b50 -o br-8acb606a3b50 -j DROP' failed: iptables: Bad rule (does a matching rule exist in that chain?)


    ... 可以在正常操作期间出现,当 Docker 尝试删除规则而不先检查其存在时。换句话说,即使有这样的警告,容器也可以顺利运行。

    关于docker - 如何更正 firewalld 和 docker/nginx 的配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66592057/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com