Convert to HAPROXY configuration

upstream portainer {
server ADDRESS:PORT;
}

server {
listen 80;

location /portainer/ {
proxy_http_version 1.1;
proxy_set_header Connection “”;
proxy_pass 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/;
}
}

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

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

You can replace:

acl portainer hdr_end(host) -i portainer.127.0.0.1.xip.io
use_backend portainer if portainer

With:

defaut_backend portainer

if needed.

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

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

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,