# HTTP / HTTPS Tunnels

> Create HTTP/HTTPS tunnels to your localhost effortlessly with Pinggy. Use a single command to share your service and access it through dynamic URLs.
> Source: https://pinggy.io/docs/http_tunnels/


# Create HTTP / HTTPS Tunnels with Pinggy

Pinggy allows you to create HTTP / HTTPS tunnels to your localhost using a single command:

First, run the service you want to share in localhost. You need to know the port where the service is running, for example `8000`. Check if the service is accessible from localhost through <a href="http://localhost:8080" target="_blank">http://localhost:8000</a>.

Command to start a tunnel to port `8000`:


```bash
# SSH - no install, works anywhere the ssh client is available
ssh -p 443 -R0:localhost:8000 free.pinggy.io
```

```bash
# Pinggy CLI - install with: npm install -g pinggy (or download the binary)
./pinggy -p 443 -R0:localhost:8000 free.pinggy.io
```


The above command will provide you http and https URLs as follows:

```
You can access local server via following URL(s):
http://fakqxzqrohxxx.a.pinggy.link
https://fakqxzqrohxxx.a.pinggy.link
```

You can access your localhost service using these URLs.

**These URLs will change every time you create a new tunnel.<br> If you want a persistent subdomain** <b><a target="_blank" href="https://pinggy.io/#prices">upgrade to Pinggy Pro</a></b>.


## Force HTTPS redirect

If you want browsers visiting your Pinggy tunnel URL to only use HTTPS, you can enable the `x:https` option. This will redirect browsers visiting any HTTP address to HTTPS.


Just pass the optional `x:https` argument at the end of the command the command. In addition, add the `-t` option right after the ssh command.


```bash
# SSH - no install, works anywhere the ssh client is available
ssh -p 443 -R0:localhost:8000 -t free.pinggy.io x:https
```

```bash
# Pinggy CLI - install with: npm install -g pinggy (or download the binary)
./pinggy -p 443 -R0:localhost:8000 -t free.pinggy.io x:https
```




## Connect to local HTTPS server

If your localhost server is an HTTPS server that only accepts TLS connections, then use the `x:localServerTls` option. This will make Pinggy tunnel connect to your local server using the HTTPS (TLS) protocol only.


```bash
# SSH - no install, works anywhere the ssh client is available
ssh -p 443 -R0:localhost:8000 -t free.pinggy.io x:localServerTls
```

```bash
# Pinggy CLI - install with: npm install -g pinggy (or download the binary)
./pinggy -p 443 -R0:localhost:8000 -t free.pinggy.io x:localServerTls
```





You can also set the server name (SNI) used to connect to your local server as by passing adding the argument: `x:localServerTls:example.com`


```bash
# SSH - no install, works anywhere the ssh client is available
ssh -p 443 -R0:localhost:8000 -t free.pinggy.io x:localServerTls:example.com
```

```bash
# Pinggy CLI - install with: npm install -g pinggy (or download the binary)
./pinggy -p 443 -R0:localhost:8000 -t free.pinggy.io x:localServerTls:example.com
```




