iT邦幫忙

0

docker 外部無法連線

  • 分享至 

  • xImage

我創建好一個nginx伺服器,透過curl http://host_ip:port 有顯示出來,但在不同網路下測試卻無法連線,請各位大神幫忙解答。

curl http://host_ip:port

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

docker network資訊

 {
        "Name": "docker_default",
        "Id": "1a3b24486029603f11f4e0dfbd0b52fbcf67900dea410da9a13fa57755fe7ba1",
        "Created": "2022-04-05T17:42:45.049988619+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.21.0.0/16",
                    "Gateway": "172.21.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "d1193b9ad3e87c3452b8924c9b3eafdb6d446ca31bc9c377fc33edc623b852f1": {
                "Name": "test",
                "EndpointID": "9b141bd41514fdaff607d5a22aa5b0791267b8d2bb8a724e011485876ace2f81",
                "MacAddress": "02:42:ac:15:00:02",
                "IPv4Address": "172.21.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "default",
            "com.docker.compose.project": "docker",
            "com.docker.compose.version": "1.29.2"
        }
    }
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
踏雪尋梅
iT邦研究生 5 級 ‧ 2022-04-06 15:27:36

關於你的問題,得先釐清「不同網路下測試卻無法連線」

這邊指的不同網絡,是指不同網段的Lan、還是其他Wan?

如果是不同網段的Lan:那要看一下你的網路架構是怎麼樣的?光看這樣的資訊實在無法排查

如果是想要Wan能訪問,要先確定你的Server是不是已經有對外了

看更多先前的回應...收起先前的回應...

您好~確定是Wan然後伺服器也能對外,想請問如果是這部分該如何去排查?謝謝!

踏雪尋梅 iT邦研究生 5 級 ‧ 2022-04-06 15:52:29 檢舉

由Wan走進Lan(Server),有經過什麼設備之類的嗎?(例如Switch,Firewall)

Web Server Firewalld Port 有開嗎?
能show docker ps,看一下嗎?

踏雪尋梅 iT邦研究生 5 級 ‧ 2022-04-06 15:53:19 檢舉

traceroute 結果如何?

小弟剛剛發現nginx設定寫錯了,目前已經ok,感謝大大回復!!

踏雪尋梅 iT邦研究生 5 級 ‧ 2022-04-06 16:23:48 檢舉

有解決就好!/images/emoticon/emoticon12.gif

我要發表回答

立即登入回答