> ## Documentation Index
> Fetch the complete documentation index at: https://ngrok.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Using ngrok with Virtual hosts (MAMP, WAMP, etc)

> Learn how to expose virtual hosts from MAMP, WAMP, and similar web servers using ngrok's host header rewriting feature.

Popular web servers such as MAMP and WAMP rely on a technique popularly referred to as 'Virtual Hosting' which means that they consult the HTTP request's `Host` header to determine which of their multiple sites they should serve. To expose a site like this it is possible to ask ngrok to rewrite the `Host` header of all requests to match what your web server expects. You can do this with the [`add-headers`](https://ngrok.com/docs/gateway/traffic-policy/actions/add-headers/) Traffic Policy action (see: [Rewriting the Host header](https://ngrok.com/docs/gateway/endpoints/http.md#rewrite-host-header)) to pick which virtual host you want to target. For example, to route to your local site `myapp.dev`, save the following as `traffic-policy.yml`:

```yaml theme={null}
on_http_request:
  - actions:
      - type: add-headers
        config:
          headers:
            host: myapp.dev
```

Then start the agent with that Traffic Policy:

```bash theme={null}
ngrok http 80 --traffic-policy-file traffic-policy.yml
```

To use the local address hostname instead, set `host` to `localhost`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.