# Convert to HAPROXY configuration

**URL:** <https://discourse.haproxy.org/t/convert-to-haproxy-configuration/896>\
**Category:** Help!\
**Created:** [January 5, 2017, 6:58am UTC](https://discourse.haproxy.org/t/convert-to-haproxy-configuration/896 "2017-01-05T06:58:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppraj](https://avatars.discourse-cdn.com/v4/letter/p/85e7bf/32.png) [@ppraj](https://discourse.haproxy.org/u/ppraj)\
**Post date:** [January 5, 2017, 6:58am UTC](https://discourse.haproxy.org/t/convert-to-haproxy-configuration/896/1 "2017-01-05T06:58:37Z")

</div>

upstream portainer {  
server ADDRESS:PORT;  
}

server {  
listen 80;

location /portainer/ {  
proxy\_http\_version 1.1;  
proxy\_set\_header Connection “”;  
proxy\_pass [http://portainer/;](http://portainer/;)  
}  
location /portainer/ws/ {  
proxy\_set\_header Upgrade $http\_upgrade;  
proxy\_set\_header Connection “upgrade”;  
proxy\_http\_version 1.1;  
proxy\_pass [http://portainer/ws/;](http://portainer/ws/;)  
}  
}

Please find this link, as I need to serve content with virtual path for the application and the example as with nginx

[https://portainer.readthedocs.io/en/stable/faq.html#how-can-i-configure-my-reverse-proxy-to-serve-portainer](https://portainer.readthedocs.io/en/stable/faq.html#how-can-i-configure-my-reverse-proxy-to-serve-portainer)

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [January 5, 2017, 9:30am UTC](https://discourse.haproxy.org/t/convert-to-haproxy-configuration/896/2 "2017-01-05T09:30:21Z")

</div>

Just use the the paragraph below which talks about haproxy. No special configuration is needed.

[https://portainer.readthedocs.io/en/stable/faq.html#how-can-i-configure-my-reverse-proxy-to-serve-portainer-using-haproxy](https://portainer.readthedocs.io/en/stable/faq.html#how-can-i-configure-my-reverse-proxy-to-serve-portainer-using-haproxy)

You can replace:

> acl portainer hdr\_end(host) -i [portainer.127.0.0.1.xip.io](http://portainer.127.0.0.1.xip.io)  
> use\_backend portainer if portainer

With:

> defaut\_backend portainer

if needed.

---

<div class="post-metadata">

**Author:** ![sungiri88](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sungiri88](https://discourse.haproxy.org/u/sungiri88)\
**Post date:** [January 5, 2017, 10:40am UTC](https://discourse.haproxy.org/t/convert-to-haproxy-configuration/896/5 "2017-01-05T10:40:29Z")

</div>

On behalf of my colleage ppraj (his posts are spammed, dont know why)

Portainer listens on 192.168.2.57:9000 . Now my HAProxy configured on another machine is has been updated with virtual path

```
   frontend http-in
    bind *:80
    option http-server-close
    option forwardfor
    acl has_portainer path_beg /portainer
    use_backend portainer_server if has_portainer

backend portainer_server
balance roundrobin
option forwardfor
server portainer 192.168.2.57:9000

```

When I hit /portainer , page come up with BAD REQUEST. The issue is the actual server does not serve with /portainer. Hence I need to strip /portainer and send the request to backend . So I did this

```
reqrep ^([^\]*\ /)portainer[/]?(.*) \1\2

```

The page does not load either , but now no BAD REQUEST . Instead I just get blank page , but when I press F12 I can see in the console and the request headers coming up . The URL now in there/css , which is not good as it needs to be 192.168.2.57:9000/css , to make it work .

The links in the page still points to 192.168.2.57:9000 , which is the actual server where it is hosted fails subsequently

---

<div class="post-metadata">

**Author:** ![sungiri88](https://avatars.discourse-cdn.com/v4/letter/s/8baadc/32.png) [@sungiri88](https://discourse.haproxy.org/u/sungiri88)\
**Post date:** [July 11, 2017, 5:27am UTC](https://discourse.haproxy.org/t/convert-to-haproxy-configuration/896/6 "2017-07-11T05:27:04Z")

</div>

Portainer listens on 192.168.2.57:9000 . Now my HAPROxy configured on another machine is has been updated with virtual path

```
   frontend http-in
    bind *:80
    option http-server-close
    option forwardfor
    acl has_portainer path_beg /portainer
    use_backend portainer_server if has_portainer

backend portainer_server
balance roundrobin
option forwardfor
server portainer 192.168.2.57:9000

```

When I hit /portainer , page come up with BAD REQUEST. The issue is the actual server does not serve with /portainer. Hence I need to strip /portainer and send the request to backend . So I did this

```
reqrep ^([^\]*\ /)portainer[/]?(.*) \1\2

```

The page does not load either , but now no BAD REQUEST . Instead I just get blank page , but when I press F12 I can see in the console and the request headers coming up . The URL now in there/css , which is not good as it needs to be 192.168.2.57:9000/css , to make it work .

The links in the page still points to 192.168.2.57:9000 , which is the actual server where it is hosted fails subsequently

---

<div class="post-metadata">

**Author:** ![dyadaval](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/dyadaval/32/357_2.png) [@dyadaval](https://discourse.haproxy.org/u/dyadaval)\
**Post date:** [December 20, 2017, 4:32am UTC](https://discourse.haproxy.org/t/convert-to-haproxy-configuration/896/7 "2017-12-20T04:32:22Z")

</div>

Hi, I am newbie and have a query to related to same topic.

NGINX handling for 10080

Hi Umpathy Girirajan,

I found your name in haproxy user list. I am newbie to haproxy and  
trying to convert the below nginx config to haproxy.  
server {  
listen 10080;  
listen [::]:10080;  
server\_name localhost;

```
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }

```

#To pass a request to an HTTP proxied server  
location / {  
proxy\_pass http://[::1]:10088;  
proxy\_set\_header Host $host;  
proxy\_redirect http://[::1] http://$host;  
}

```
}

```

haproxy equivalent:

frontend fe\_http\_sne\_in  
bind 0.0.0.0:10080  
bind :::10080  
option forwardfor  
default\_backend be\_sne\_insecure

backend be\_sne\_insecure  
mode http  
http-request set-header localhost  
option forwardfor  
server srv01 localhost:10088

Is this correct??

Please let me know.

thanks,
