There are multiple ways to reach our locahost web server depends on your requirements.

  1. Using HTTP Tunnel.
  2. Using TLS tunnel.
  3. Using TCP tunnel.

1. Using HTTP Tunnel:

a. Prepare Apache/Nginx web server

We will run Apache or Nginx web server through docker:

docker run -p 3000:80 httpd
docker run -p 3000:80 nginx

This will run Apache/Nginx web server in localhost:3000

b. Start HTTP tunnel

Run HTTP tunnel and point it to Apache/Nginx web server

loclx tunnel http --subdomain apache --to localhost:3000

After creating the tunnel and getting a shareable link to our website, we can access the website through https://apache.loclx.io or http://apache.loclx.io.

2. Using TLS tunnel

a. Prepare Apache/Nginx web server

We will run Apache/Nginx web server through docker as we did with HTTP tunnel above:

docker run -p 3000:80 httpd
docker run -p 3000:80 nginx

This will run Apache/Nginx web server in localhost:3000

b. Start TLS tunnel

You either can:

  • Let LocalXpose client to terminate the TLS traffic by providing the TLS certificate , so in this case you don't need to configure your Apache/Nginx web server TLS settings for example:
loclx tunnel tls --to localhost:3000 --crt /path/to/crt.pem --key /path/to/key.pem
loclx tunnel tls --to localhost:443

Now the TLS tunnel will be accessible from the internet through https://your-domain.com.

Note that TLS tunnel will only accept connection from the internet on port 443.

Since you are using TLS tunnel to access your localhost webserver, you will not be able to use HTTP middlewares.

3. Using TCP tunnel

Since HTTP works on top of TCP, then a TCP tunnel will also works.

a. Prepare Apache/Nginx web server as we did before in TLS and HTTP tunnel.

b. Start TCP tunnel

loclx tunnel tcp --port 8888 --to 3000

This will create a TCP tunnel us.loclx.io:8888, you can access your Apache/Nginx webserver from the internet through http://us.loclx.io:8888

Since you are using TCP tunnel to access your localhost webserver, you will not be able to use HTTP middlewares.


© xLab 2023. All Rights Reserved