# Intercept HTTP CONNECT Method / Tunnel only

**URL:** https://discourse.haproxy.org/t/intercept-http-connect-method-tunnel-only/6945
**Category:** Help!
**Created:** [September 29, 2021, 9:35am UTC](https://discourse.haproxy.org/t/intercept-http-connect-method-tunnel-only/6945 "2021-09-29T09:35:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cerberus247](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@cerberus247](https://discourse.haproxy.org/u/cerberus247)
#### Post date: [September 29, 2021, 9:35am UTC](https://discourse.haproxy.org/t/intercept-http-connect-method-tunnel-only/6945/1 "2021-09-29T09:35:56Z")

</div>

Hi,

I’m fairly new to HAProxy and trying to establish if it is possible to replicate something that we can do within Fiddler **[Fiddler Classic](https://www.telerik.com/fiddler/fiddler-classic)** but move to HAProxy…

Essentially, all I want to do is let all traffic pass through to another internal/internet proxy and intercept only a specific HTTP CONNECT method.

E.G. If host = **[example.com](http://example.com)** then rewrite to host = **[example.co.uk](http://example.co.uk)**.  
As a result, all traffic will tunnel to the new host…

For example in Fiddler I can script like this :

```auto
// Capture only example.com and rewrite host to example.co.uk for the CONNECT method and tunnel
if (oSession.HTTPMethodIs("CONNECT") && (oSession.host == "example.com:443")) { 
	oSession.host = "example.co.uk:443";
}

```

Client → HAProxy [Intercept CONNECT / Rewrite] → Internal Proxy → Internet

Is this even possible with HAProxy…???  
I cannot seem to find exact similar use-cases…

Thanks!  
J

---

<div class="post-metadata">

### Author: ![rhada](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/rhada/32/585_2.png) [@rhada](https://discourse.haproxy.org/u/rhada)
#### Post date: [October 1, 2021, 3:12pm UTC](https://discourse.haproxy.org/t/intercept-http-connect-method-tunnel-only/6945/2 "2021-10-01T15:12:12Z")

</div>

Hello,

You can try to set up un acl, to send requests to defined backend and then rewrite Host Header :

```auto
acl mydomain hdr(host) -i mydomain.com
use_backend example.com if mydomain

backend example.com
    http-request set-header Host example.com
    server example.com example.com:80 check

```

This config replace host header when forwarding the request to the backend. We use it with clear http and it just works. not sur with ssl backend.
