Expose Apache/Nginx web server
This tutorial will explain how to expose a localhost Apache/Nginx web server and give it a shareable link that is accessible from the internet.
There are multiple ways to reach our locahost web server depends on your requirements.
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
Or configure your Apache or Nginx web server to deal with TLS termination by using
mod_ssl
module for Apache and for Nginx you can follow this tutorial https://nginx.org/en/docs/http/configuring_https_servers.html, then you don't need to pass the TLS certificate to LocalXpose client for example:
loclx tunnel tls --to localhost:443
Now the TLS tunnel will be accessible from the internet through https://your-domain.com
.
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
Last updated
Was this helpful?