Search code examples
linuxarmubuntu-20.04connection-refusedfailed-to-connect

oraclecloud ubuntu20 Connection refused


I have a strange problem, I installed various services directly on the server, but I can't access them (only happens on OracleCloud's server, I have never encountered this problem with other Clouds). The following is the introduction of my test, start a new instance (ARM Ubuntu20), install nginx

can access it normally through localhost

$ curl localhost:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    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>

abnormal access through the network

$ curl 138.*.*.50:80 

curl: (7) Failed to connect to 138.*.*.50 port 80: No route to host

stop the nginx service. Install docker

start the nginx container, map port 80 to port 80 of the host

$ docker run --name nginx_test -p 80:80 -d nginx

and both localhost and the network can access it

root@instance-20220222-2204:/etc/nginx# curl localhost:80
<!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>
root@instance-20220222-2204:/etc/nginx# curl 138.*.*.50:80
<!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>

The following is a screenshot of my operation, during which I did not do anything to modify the firewall and security group

nginx

docker-nginx


Solution

  • Empty rules solved my problem

    ufw disable

    iptables -F