【问题标题】:Can not access to GCP VM Instance via external IP although apache2 started尽管 apache2 已启动,但无法通过外部 IP 访问 GCP VM 实例
【发布时间】:2020-08-23 10:10:17
【问题描述】:

我在 gcp 上创建了一个测试 vm 实例:

似乎没问题,但我无法通过外部 ip 访问,因为文档中说https://cloud.google.com/community/tutorials/setting-up-lamp

请给我一些建议,谢谢。

==================================

卷曲 --head http://35.240.177.89/ curl: (7) 连接35.240.177.89端口80失败:操作超时

卷曲 --head https://35.240.177.89/ curl: (7) 连接35.240.177.89端口443失败:操作超时

netstat -lntup: result

【问题讨论】:

  • 使用命令curl --head http://IPcurl --head https://IP。替换为您的 IP 地址。结果如何?使用每个命令和输出编辑您的问题。
  • @JohnHanley 我刚刚更新了结果
  • 添加此命令的输出:netstat -lntup。如果您配置了 HTTPS 端口 443,则输出应显示端口 80 的 LISTEN。确保他们正在侦听 0.0.0.0 而不是 127.0.0.1。如果您有正确的侦听器,那么您有防火墙阻止访问,或者您指定了错误的 IP 地址。确保 Linux 防火墙已禁用或允许端口 80 和 443。
  • 我只是添加了net stat结果和外部IP图像,似乎正确..

标签: google-cloud-platform apache2


【解决方案1】:

假设您的 Linux 启用了双栈,带有 :::80 的 netstat 意味着 Apache2 正在侦听所有网络接口的 IPv4 和 IPv6 端口 80。您可以使用以下命令进行检查。 0 值表示启用了双栈。

cat /proc/sys/net/ipv6/bindv6only

鉴于上述情况,您的系统很可能没有允许端口 80 的 iptables 规则。假设 Ubuntu 18.04(针对您的发行版进行修改):

备份iptables规则:

sudo iptables-save > iptables.backup

允许输入端口 80:

sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT

可选地允许输入端口 443:

sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT

【讨论】:

    猜你喜欢
    • 2021-04-22
    • 2018-02-26
    • 1970-01-01
    • 2020-04-02
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-09
    相关资源
    最近更新 更多