Skip to content

Commit 86135b2

Browse files
committed
grammar done
1 parent d0390f8 commit 86135b2

File tree

1 file changed

+11
-11
lines changed
  • src/content/post/2025/04-20-ssh-tunnel-docker

1 file changed

+11
-11
lines changed

src/content/post/2025/04-20-ssh-tunnel-docker/index.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ Above is shown only the relevant Traefik configuration for the SSH tunnel contai
296296

297297
## Tunneling multiple services
298298

299-
Sometimes your app runs more than a single service, e.g. frontend and backend. If you expose just a frontend from port 3000 note that `localhost` from e.g. `localhost:5000` wont be resolved, so you need to tunnel all services and set tunneled URLs in your `.env` files.
299+
Sometimes your app runs more than a single service, e.g. frontend and backend. If you expose just the frontend from port 3000, note that `localhost` from, e.g. `localhost:5000` won't be resolved. Therefore, you need to tunnel all services and set the tunneled URLs in your `.env` files.
300300

301-
How to have more than a single tunnel? Maybe your first thought is to run multiple SSH server containers, but fortunately that is not needed, you can tunnel as many services you want through a single SSH connection. You just need to expose multiple ports on SSH container and map them to multiple Traefik hosts with labels, like shown bellow:
301+
How to have more than one tunnel? Your first thought might be to run multiple SSH server containers, but fortunately, that is not necessary. You can tunnel as many services as you want through a single SSH connection. You just need to expose multiple ports on the SSH container and map them to multiple Traefik hosts with labels, as shown below:
302302

303303
```yml title="docker-compose.yml"
304304
version: '3.8'
@@ -364,19 +364,19 @@ networks:
364364
external: true
365365
```
366366
367-
If you have a really big number of services to tunnel you might want to use a VPN to access all ports by default, but thats rarely the case.
367+
If you have a large number of services to tunnel, you might want to use a VPN to access all ports by default, but that's rarely the case.
368368
369-
Another point to make is that SSH tunnel technique is most suitable for temporary exposing services for demo purposes. For permanent tunnels you would need to add `autossh` to keep connection alive, but there are a better tools for permanent tunnels, like [rapiz1/rathole](https://github.com/rapiz1/rathole) or [fatedier/frp](https://github.com/fatedier/frp).
369+
Another point to make is that the SSH tunnel technique is most suitable for temporarily exposing services for demo purposes. For permanent tunnels, you would need to add `autossh` to keep the connection alive, but there are better tools for permanent tunnels, such as [rapiz1/rathole](https://github.com/rapiz1/rathole) or [fatedier/frp](https://github.com/fatedier/frp).
370370

371-
## Open firewall on VPS
371+
## Open the firewall on the VPS
372372

373-
For the main SSH connection you will need to open a port in your VPS firewall, port `1080` in this example. Additionally, if you want to access tunnels directly via port in the browser without Traefik, you will need to open those ports too. Be mindful not to open to many unneeded ports as every new opened port increases the attack surface.
373+
For the main SSH connection, you will need to open a port in your VPS firewall, port `1080` in this example. Additionally, if you want to access tunnels directly via a port in the browser without Traefik, you will need to open those ports as well. Be mindful not to open too many unnecessary ports, as every newly opened port increases the attack surface.
374374

375375
<Image {...IMAGE_SIZES.FIXED.MDX_MD} src={FirewallImage} alt="Example opened ports in the firewall" />
376376

377377
## Running the tunnel
378378

379-
You start the tunnel with a single command like bellow. `-R` option means remote port forwarding, then you have two `IP:port` pairs, the first pair is remote, the second is local. At the end you have the VPS host.
379+
You start the tunnel with a single command like below. The `-R` option means remote port forwarding, followed by two `IP:port` pairs. The first pair is remote, and the second is local. At the end, you have the VPS host.
380380

381381
```bash
382382
# command format
@@ -392,7 +392,8 @@ https://preview1.my-domain.com
392392
# terminate tunnel, like any ssh connection
393393
exit
394394
```
395-
You can open the multiple tunnels with a single command, just specify the tunnels one after another before the host. Note that you must have these tunnels defined in your `docker-compose.yml` of SSH server (exposed ports and Traefik host labels).
395+
396+
You can open multiple tunnels with a single command. Just specify the tunnels one after another before the host. Note that you must have these tunnels defined in your `docker-compose.yml` for the SSH server (exposed ports and Traefik host labels).
396397

397398
```bash
398399
# tunnel frontend at port 3000 and backend at port 5000
@@ -413,9 +414,9 @@ https://preview2.my-domain.com/api
413414

414415
## Conclusion
415416

416-
Port forwarding is a basic networking technique very familiar to network engineers, but maybe not often enough utilized by developers. And it can be very useful and practical, especially in a remote work setting. Like described in this tutorial, you just need to run a single container, configure the client and firewall, but once you have it it can save you a lot of time and energy in a long run.
417+
Port forwarding is a basic networking technique that is very familiar to network engineers, but perhaps not often utilized by developers. It can be very useful and practical, especially in a remote work setting. As described in this tutorial, you just need to run a single container, configure the client and firewall, and once you have it set up, it can save you a lot of time and energy in the long run.
417418

418-
SSH remote port forwarding is just one of the many useful and cool SSH networking tricks, there are many others like dynamic port forwarding, SSH agent forwarding, X11 forwarding, SSH file system, etc., do you use some of them? Please share in the comments bellow.
419+
SSH remote port forwarding is just one of the many useful and cool SSH networking tricks. There are many others like dynamic port forwarding, SSH agent forwarding, X11 forwarding, SSH file system, etc. Do you use some of them? Please share in the comments bellow.
419420

420421
## References
421422

@@ -425,4 +426,3 @@ SSH remote port forwarding is just one of the many useful and cool SSH networkin
425426
- Useful discussion that suggests to use the existing tunnel mod https://github.com/linuxserver/docker-openssh-server/issues/22
426427
- The list of all available Linuxserver mods https://github.com/linuxserver/docker-mods, https://mods.linuxserver.io
427428
- The list of all available Linuxserver images https://www.linuxserver.io/our-images
428-

0 commit comments

Comments
 (0)