# Expose Apache/Nginx web server

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

1. [Using HTTP Tunnel.](#1.-using-http-tunnel)
2. [Using TLS tunnel.](#2.-using-tls-tunnel)
3. [Using TCP tunnel.](#3.-using-tcp-tunnel)

## 1. Using HTTP Tunnel:&#x20;

### 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`.

{% hint style="info" %}
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](/docs/tunnels/http/http-s-plugins.md).
{% endhint %}

## 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`

{% hint style="info" %}
Since you are using TCP tunnel to access your localhost webserver, you will not be able to use [HTTP middlewares](/docs/tunnels/http/http-s-plugins.md).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://localxpose.gitbook.io/docs/tutorials/expose-apache-nginx-web-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
