Expose the ports for http and ssh. By default, gitea exposes 3000 for http and 22 for ssh. We want our application to listen externally on port 80, but we need to map our ssh to a different port because 22 is used by the host.
# expose container `http` port 3000 on host `http` port 80
dokku proxy:ports-add gitea http:80:3000
# expose the container port 22 on host port 2222
dokku docker-options:add git deploy -p 2221:22
Add a rule in your firewall to allow connections on 2221.
This simple setup can help us expose our local development environment to the public internet. I usually paid for ngrok, but the last time I tried them, they were expensive, and their customer support was terrible.
For a small-size project, we can build our own small ngrok with Linux, Caddy, and SSH port forwarding.
Requirements:
A VPS with Linux. In this example, we will use Ubuntu 20.01 LTS
SSH access to your server
Caddy
A domain name. In this example, we will use mydomain.io
Add DNS record
We need to add two A records to our domain DNS zone:
An A record pointing to our server’s IP address
A wildcard A record pointing to our server’s IP address
For example, if our server IP address is 5.164.71.442, our records will look like this:
caddy reload
> 2023/05/30 17:55:25.272 INFO using adjacent Caddyfile
And our server is ready.
Create an SSH tunnel
With SSH, you can create a secure connection between your computer and the server, with the services relayed, i.e., every request to the server will be forwarded to your local development environment.
For example, if we are building our application in localhost:8000, we can do the following: