Bring your app online using SSH with a custom domain for free

Hi, I am Vivek, a 26 years old developer from India. I love making apps. You can check my github for some of my open source projects.
Search for a command to run...

Hi, I am Vivek, a 26 years old developer from India. I love making apps. You can check my github for some of my open source projects.
No comments yet. Be the first to comment.
Migrating a production database is often a high-stakes operation. Traditional "dump and restore" methods require significant maintenance windows, leading to service downtime. To solve this, PostgreSQL offers Logical Replication, a native mechanism th...

Ever found yourself in the endless cycle of "delete Docker image, redeploy, repeat" to keep your Dokku apps updated? You’re not alone. If your Dokku-deployed application relies directly on a Docker image (perhaps from Docker Hub or your private regis...

Lately, my internet has been throwing tantrums — not because the connection itself is bad, but because every time the power blinks, my router decides it's time for a little nap. Naturally, the obvious

So, one day I saw my old laptop sitting there, collecting dust like it was auditioning for a role in an apocalypse movie. And then it hit me: "Why not turn it into a server?" There was just one minor hiccup. Its Ethernet port was as dead as my dreams...

Recently I was tasked with setting up kubernetes cluster with an Nginx Ingress. As a newcomer to Kubernetes, I tackled this setup and learned a thing or two along the way. Let me walk you through my experience and share some helpful tips. The Goal: S...

If you're a developer you must've encountered a situation where localhost just wouldn't work for you, maybe you wanted to show off your project to someone else or needed to set up a public URL for a webhook. There are countless situations where you want your project to be accessible from the internet while it is still in the development phase.
What if I told you there is a way to do this with tools you're already using?

Yeah, you read that right, you can bring your application online using SSH.
Why go through the effort when there are free third-party services like ngrok?
The problem with ngrok or any third-party services is that they don't provide a dedicated domain, meaning every time you restart your ngrok client it will give you a different domain and you'll have to change the configuration all over again, in all fairness you could buy a paid plan to have a custom domain setup as well but let's try it my way.
Before we begin, as the title suggests this is not entirely free. I know I said free and it is to some extent, but it is only free if you're already having a domain and a server. A domain may not be a fancy one but can be acquired for free from Freenom. And there are free tiers available from different cloud providers.
Once you have got a server up and running in the cloud, ssh into the server and install Nginx.
sudo apt install nginx
After the successful installation head into the /etc/nginx/sites-avaialble directory and create a new server configuration using sudo touch tunnel.conf then add the following configuration.
server {
listen 80;
listen [::]:80;
server_name tunnel.yourdomain.com;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header Accept-Encoding gzip;
}
}
replace tunnel.yourdomain.com with your domain. Also, add A record that points to your server IP for the same.
You can also use Certbot to get an SSL certificate for your domain.
Now that nginx is listening on the server, every time you want to bring your application online just run the following command and access it from your specified domain.
ssh -R remote_port:host:host_port -i ~/.ssh/private_key user@yourserver.com
change the remote_port to 8080, host to localhost & host_port to whatever your application is listening on.
Also, your ssh connection may get disconnected if there is no activity in a while, to keep the connection alive add ServerAliveInterval 60 at the end of ~/.ssh/config file.