DEV Community

Cover image for LocalTunnel Server Setup Documentation
Durrell  Gemuh
Durrell Gemuh

Posted on

LocalTunnel Server Setup Documentation

LocalTunnel Server Setup Documentation

1. Files

1.1 docker-compose.yml

version: "3.8"

services:
  lt-server:
    image: defunctzombie/localtunnel-server:latest
    container_name: lt-server
    restart: always
    ports:
      - "3000:3000"          
    networks:
      - localtunnel-net
    command: bin/server --port 3000 --host 0.0.0.0 

  localtunnel-nginx:
    image: nginx:latest
    container_name: localtunnel-nginx
    depends_on:
      - lt-server
    restart: always
    ports:
      - "8081:80"            
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./site.conf:/etc/nginx/conf.d/default.conf:ro
    networks:
      - localtunnel-net

networks:
  localtunnel-net:
    driver: bridge
Enter fullscreen mode Exit fullscreen mode

1.2 nginx.conf

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/conf.d/*.conf;
}
Enter fullscreen mode Exit fullscreen mode

1.3 site.conf

server {
    listen 80;

    location / {
        proxy_pass http://lt-server:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}
Enter fullscreen mode Exit fullscreen mode

1.4 Running LocalTunnel Client Command

nohup npx localtunnel --port 3000 --host http://34.68.37.115:8081 > tunnel.log 2>&1 &
Enter fullscreen mode Exit fullscreen mode
  • This runs LocalTunnel in the background and logs output to tunnel.log.
  • Example log output:
nohup: ignoring input
your url is: http://angry-liger-20.34.68.37.115
Enter fullscreen mode Exit fullscreen mode

2. Installation

2.1 Prerequisites

  • Docker & Docker Compose installed.
  • Node.js and npx installed (for running the LocalTunnel client).

2.2 Steps

  1. Clone or copy the configuration files into a directory:
mkdir ~/localtunnel
cd ~/localtunnel
# Add docker-compose.yml, nginx.conf, site.conf
Enter fullscreen mode Exit fullscreen mode
  1. Start the LocalTunnel server and Nginx reverse proxy:
docker-compose up -d
Enter fullscreen mode Exit fullscreen mode
  • lt-server listens internally on port 3000.
  • localtunnel-nginx exposes port 8081 externally.
  1. Verify containers are running:
docker ps
Enter fullscreen mode Exit fullscreen mode

3. Usage

3.1 Start LocalTunnel Client

nohup npx localtunnel --port 3000 --host http://<your-server-ip>:8081 > tunnel.log 2>&1 &
Enter fullscreen mode Exit fullscreen mode
  • Replace <your-server-ip> with your public server IP or domain.
  • tunnel.log stores the output including your public URL.
  • Example:
your url is: http://angry-liger-20.34.68.37.115
Enter fullscreen mode Exit fullscreen mode

3.2 Check Logs

cat tunnel.log
Enter fullscreen mode Exit fullscreen mode
  • Confirms that the tunnel is running and gives the public URL.

3.3 Stop Tunnel

  • Find the process and kill it:
jobs
kill %1   # or the relevant job number
Enter fullscreen mode Exit fullscreen mode

Top comments (0)