Report this

What is the reason for this report?

How to open port for specific IP (Droplet with VPN)

Posted on December 19, 2023

I have a Wireguard VPN on my droplet and want to open ports for my email server which is connected via VPN. As i have seen the firewall only supports opening ports for specific IP’s from the outside? So is it possible or should i route it? I already tried it to route with nginx with this but it did not work

# nginx wireguard config
server {
       listen 51820;

       location / {
               proxy_pass http://wireguard:51820;
               proxy_set_header Host $host;
               proxy_set_header X-Real-IP $remote_addr;
       }
}


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya @craftycodes,

In order to open a port there is something that needs to listen to it. Opening a port essentially means allowing network traffic to flow in and out of a specific communication endpoint on a Droplet. However, for that port to be useful, there needs to be a program or service on the computer that is actively listening to that port.

Think of a port as a door, and the service as the thing behind the door. Opening the door (port) doesn’t do much if there’s nothing on the other side to interact with. When a service is set to listen on a specific port, it means that it’s waiting for incoming connections or data on that port.

Anyway, in order open a port on your Droplet you need to use your firewall service, I would asume UFW.

First check the status

sudo ufw status

Then you can allow a port like so

sudo ufw allow 22/tcp

Where 22 is your port and tcp is the time of connection.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Dark mode is coming soon.