我尝试从我的服务器连接到 paypal、github 和 stripe,但每次连接尝试都以“连接超时”结束。我使用 ufw 作为防火墙,我的默认传入规则是拒绝,默认传出规则是允许。我已经尝试将 stripe 的 ip 添加到 ufw,但仍然失败。问我任何问题,我都会尝试提供有关该问题的更多信息,我只是累了,我希望提前修复这个问题。
更新:
我正在使用带有正确库的 php 来处理 paypal 和 stipe。对于 github,我使用的是 wget。
这是 wget 的输出:
--2022-04-28 22:26:51-- https://github.com/xx/gx/releases/download/v1.0.0-beta/xx
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... failed: Connection timed out.
Retrying.
--2022-04-28 22:27:24-- (try: 2) https://github.com/xx/gx/releases/download/v1.0.0-beta/xx
Connecting to github.com (github.com)|140.82.121.3|:443... failed: Connection timed out.
Retrying.
--2022-04-28 22:27:57-- (try: 3) https://github.com/xx/gx/releases/download/v1.0.0-beta/xx
Connecting to github.com (github.com)|140.82.121.3|:443... failed: Connection timed out.
Retrying.
--2022-04-28 22:28:32-- (try: 4) https://github.com/xx/gx/releases/download/v1.0.0-beta/xx
Connecting to github.com (github.com)|140.82.121.3|:443... failed: Connection timed out.
Retrying.
--2022-04-28 22:29:08-- (try: 5) https://github.com/xx/gx/releases/download/v1.0.0-beta/xx
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-04-28 22:29:15 ERROR 404: Not Found.
我刚刚注意到,经过几次尝试,wget 可以成功连接……。但对于 php 来说情况并非如此。所以我在想这可能是 ufw 或 iptables 的问题?
答案1
问题在于 iptables 配置在某种程度上与 docker 配置发生冲突。
我使用这些命令来重置 iptables:
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT