How to directly access the server with a port without doing any reverse proxying?

June 26, 2018 400 views
Nginx Node.js Applications Ubuntu

hi i'm new to this, when i'm running my application, i can't access my application with public ip and the port number, but i can successfully access after reverse proxying with nginx, how could i directly access the app?

1 Answer

It could be that there is a firewall blocking external connections via that specific port, here are some ways to debug:

First - confirm that the port is definitely blocked externally by running telnet YOUR_IP_ADDRESS THE_PORT_NUMBER from the command line. For example: telnet 123.45.123.32 80 if you get a response:

Trying 123.45.123.32...
Connected to123.45.123.32.
Escape character is '^]'.

then the port is actually open and the problem might be on your local device.

Still not solved? Check if it is a software firewall, running on your Droplet:

  • UFW is a commonly used firewall control software, to check if it is running, run sudo ufw status verbose (full reference here)
  • IP Tables are the more complicated underlying functionality that UFW controls, if you run sudo iptables -nL you will see a list of any iptables rules that are blocking certain ports. If you just see:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

it means no ports are blocked.

Still not solved? Check if there's a DigitalOcean cloud firewall blocking external connections: Go to your Droplet's page in the Control Panel and click on the Networking tab. Are there any active firewall rules listed? Read more about Cloud Firewalls here

by Hazel Virdó
UFW, or Uncomplicated Firewall, is an interface to iptables that is geared towards simplifying the process of configuring a firewall. While iptables is a solid and flexible tool, it can be difficult for beginners to learn how to use it to properly configure a firewall. If you're looking to get started securing your network, and you're not sure which tool to use, UFW may be the right choice for you. This tutorial will show you how to set up a firewall with UFW on Ubuntu 16.04.
Have another answer? Share your knowledge.