banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

[Docker]Nginx出现 is not served on this interface问题

[Docker] Nginx 出现 is not served on this interface 问题

很多云服务商的 VPS,比如阿里云 ECS/ AWS EC2 都默认开启了 ipv6 支持。使用 docker 跑 nginx 官方容器时,如果网络配置不当会出现

404 Site 172.17.0.x is not served on this interface

一般是因为服务器同时启用了 ipv6 和 ipv4,按需要关闭一个,如果同时启用的话,需要单独处理一下

# 使用 ipv6,隐式向下兼容 ipv4

server{
listen [::]:80 default ipv6_only=on;
server_name _ ;
}

同时启用 ipv6 和 ipv4,显式向下兼容

# 同时启用 ipv6 和 ipv4,显式向下兼容
server{
listen 80 default;
listen [::]:80 ipv6_only=on;
server_name _ ;
}

只使用 ipv4,不兼容 ipv6

# 只使用 ipv4,不兼容 ipv6
server{
listen 80 default;
server_name _ ;
}

关闭 docker 的 IPv6 支持,这里不推荐使用

vi /etc/docker/daemon.json

在 /etc/docker/daemon.json 增加关闭 ipv6 的设置

{
...
ipv6='False',
......
}

404 Site 172.17.0.x is not served on this interface

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.