# Access Internet Through Proxy

**URL:** <https://discourse.haproxy.org/t/access-internet-through-proxy/7575>\
**Category:** Configuration Samples\
**Created:** [April 15, 2022, 1:45pm UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575 "2022-04-15T13:45:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kolo](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kolo](https://discourse.haproxy.org/u/kolo)\
**Post date:** [April 15, 2022, 1:45pm UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/1 "2022-04-15T13:45:56Z")

</div>

Hi Community! I have problem with accessing internet through proxy. Here’s the configuration.

frontend main  
bind \*:5000  
#acl url\_static path\_beg -i /static /images /javascript /stylesheets  
#acl url\_static path\_end -i .jpg .gif .png .css .js  
#use\_backend static if url\_static  
#default\_backend app  
use\_backend %[req.hdr(Host),lower]  
backend [web1.com](http://web1.com)  
server web1 localhost:8080 check  
backend [web2.com](http://web2.com)  
server web2 localhost:8081 check  
backend [web3.com](http://web3.com)  
server web3 localhost:8082 check

It should be error “Can’t be reach”.

What i want to make, if anyone want access youtube, the haproxy give access to outside.  
Any solution? Thanks!

---

<div class="post-metadata">

**Author:** ![willy](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@willy](https://discourse.haproxy.org/u/willy)\
**Post date:** [April 15, 2022, 2:04pm UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/2 "2022-04-15T14:04:06Z")

</div>

It’s really unclear. I guess you mean you are installing haproxy in front of another outgoing proxy like Squid so that haproxy is configured as the proxy in the browser, is that it ? But in this case why would you have 3 different hosts on 3 different ports ?

Also, you need to use “mode http” in your frontends and backends (or place that in a “defaults” section), otherwise the connections are forwarded in TCP without waiting for the request, and here you’ll end up failing to connect and directly closing in the face of the client, which might explain the error you’re receiving.

---

<div class="post-metadata">

**Author:** ![kolo](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kolo](https://discourse.haproxy.org/u/kolo)\
**Post date:** [April 15, 2022, 2:18pm UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/3 "2022-04-15T14:18:51Z")

</div>

yup, i did the defaults section but not in copy that. Sorry for the unclear.

I have 3 website that can be access only by set the windows proxy into my ip and ports. The problem comes when i want to access internet like youtube, google, etc. I have to turn off the proxy setting first and i can watch the youtube. Is there any solution for that?

---

<div class="post-metadata">

**Author:** ![kolo](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kolo](https://discourse.haproxy.org/u/kolo)\
**Post date:** [April 15, 2022, 2:24pm UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/4 "2022-04-15T14:24:00Z")

</div>

![haproxy](https://us1.discourse-cdn.com/flex016/uploads/haproxy/original/2X/3/3662bae15da1fd2406b058d24afb9a780ff993f9.png)

---

<div class="post-metadata">

**Author:** ![willy](https://avatars.discourse-cdn.com/v4/letter/w/c2a13f/32.png) [@willy](https://discourse.haproxy.org/u/willy)\
**Post date:** [April 15, 2022, 4:41pm UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/5 "2022-04-15T16:41:03Z")

</div>

OK got it.

Then you’re not using the right tool. Haproxy is a reverse proxy, not a forward proxy. Even using it like this in your browser will not work for SSL sites because your browser will send a CONNECT request that haproxy will forward to the server and that the server will not understand. You need to use a forward proxy to do what you describe. Squid ( [http://squid-cache.org/](http://squid-cache.org/) ) is the best known one, but there are others.

---

<div class="post-metadata">

**Author:** ![kolo](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@kolo](https://discourse.haproxy.org/u/kolo)\
**Post date:** [April 15, 2022, 4:43pm UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/6 "2022-04-15T16:43:52Z")

</div>

wow thanks for the solution!

---

<div class="post-metadata">

**Author:** ![curious](https://avatars.discourse-cdn.com/v4/letter/c/6bbea6/32.png) [@curious](https://discourse.haproxy.org/u/curious)\
**Post date:** [September 20, 2023, 7:12am UTC](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/7 "2023-09-20T07:12:29Z")

</div>

Moderator @willy [notes](https://discourse.haproxy.org/t/access-internet-through-proxy/7575/5) (April’22):

> Haproxy is a reverse proxy, not a forward proxy.

At HAProxyConf 2019, Julien Pivotto [explains](https://www.haproxy.com/user-spotlight-series/haproxy-as-egress-controller)

> how Inuits uses HAProxy in an unconventional way: as a forward proxy to route outgoing traffic.

I assume Julien had a special use case and HAProxy isn’t a typical forward proxy, can someone comment on the nuances?
