0

I have a simple Python server on a DigitalOcean Ubuntu droplet that should serve the index.html file in the /dist folder:

port = 8000
os.chdir(os.path.join(os.path.dirname(__file__), 'dist'))
Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(('', port), Handler)
print('Serving at port ', port)
httpd.serve_forever()

I have no cloud firewalls running on this box. I ran 'sudo ufw allow 80/tcp' to open the firewall and if I run ufw status it shows port 80 as being open to everybody. I ran 'sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8000' to redirect traffic from port 80 to port 8000.

If I run nmap from another box, the only open port is ssh on 22. Port 80 is filtered. Navigating to the host in my browser results in a connection timeout. Trying to serve directly from port 80 yields the same results. If I try nmap or netstat locally, the port shows open but the server crashes (connection reset by peer, no other useful error info). What could be causing this?

0

Turns out I had to enable the DigitalOcean firewall and set it up, otherwise it was just blocking all non-ssh connections.

0

Run

ufw allow 8000/tcp

to enable port 8000. (If you want to use port 80 replace 8000 by 80.)

If this does not work you might need to force the change. (Never had to use that until now.)

Reason for this

Even if no external firewall is configured Ubuntu is configured to allow only ssh (and maybe other ports depending on the base image you have chosen).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.