# Can access one service via HAProxy but not others

**URL:** <https://discourse.haproxy.org/t/can-access-one-service-via-haproxy-but-not-others/10072>\
**Category:** Help!\
**Created:** [July 29, 2024, 4:10pm UTC](https://discourse.haproxy.org/t/can-access-one-service-via-haproxy-but-not-others/10072 "2024-07-29T16:10:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniyal](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@Daniyal](https://discourse.haproxy.org/u/Daniyal)\
**Post date:** [July 29, 2024, 4:10pm UTC](https://discourse.haproxy.org/t/can-access-one-service-via-haproxy-but-not-others/10072/1 "2024-07-29T16:10:17Z")

</div>

Hi, I am running docker container services on my host ‘[host-192-168-1-100.example.com](http://host-192-168-1-100.example.com/)’ which i can access like ‘[host-192-168-1-100.example.com](http://host-192-168-1-100.example.com/):port’.

I want proxy three of my services on different ports and i am using url-based routing like this

```auto
global
    log 127.0.0.1 local2

    chroot /var/lib/haproxy
    pidfile /var/run/haproxy.pid
    maxconn 4000
    user haproxy
    group haproxy
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats

    # utilize system-wide crypto-policies
    ssl-default-bind-ciphers PROFILE=SYSTEM
    ssl-default-server-ciphers PROFILE=SYSTEM

defaults
    mode http
    log global
    option httplog
    option dontlognull
    option http-server-close
    option forwardfor except 127.0.0.0/8
    option redispatch
    retries 3
    timeout http-request 10s
    timeout queue 1m
    timeout connect 10s
    timeout client 1m
    timeout server 1m
    timeout http-keep-alive 10s
    timeout check 10s
    maxconn 3000

frontend http_front
    bind *:80
    redirect scheme https code 301 if !{ ssl_fc }

frontend https_front
   bind *:443 ssl crt /etc/ssl/private/haproxy.pem

        

    use_backend serviceone if { path /node-1/serviceone } || { path_beg /node-1/serviceone/ } 
    use_backend servicetwo if { path /node-1/servicetwo } || { path_beg /node-1/servicetwo/ }
    use_backend servicethree if { path /node-1/servicethree } || { path_beg /node-1/servicethree/ }

backend serviceone
    http-request replace-path /node-1/serviceone(/)?(.*) /\2
    server node-1 host-192-168-1-100:8443 check ssl verify none

backend servicetwo
    http-request replace-path /node-1/servicetwo(/)?(.*) /\2
    server node-1 host-192-168-1-100:6443 check ssl verify none

backend servicethree
    http-request replace-path /node-1/servicethree(/)?(.*) /\2
    server node-1 host-192-168-1-100:443 check ssl verify none

```

I can access all my containers without HAproxy, and I can access ServiceOne via HAproxy at [https://fqdn/node-1/serviceone](https://fqdn/node-1/serviceone). But, servicetwo shows me a 401 Unauthorized Authentication Required. Since I can access it without HAproxy, which directs me to a login page where I can enter my credentials, I don’t understand why it is showing me this error directly through HAproxy instead of taking me to the login page. Also, servicethree is also not accessible.

My servicetwo is runing on http.

Any help would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![Daniyal](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@Daniyal](https://discourse.haproxy.org/u/Daniyal)\
**Post date:** [August 1, 2024, 1:47pm UTC](https://discourse.haproxy.org/t/can-access-one-service-via-haproxy-but-not-others/10072/2 "2024-08-01T13:47:03Z")

</div>

can anyone help with this?

---

<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:** [August 1, 2024, 1:54pm UTC](https://discourse.haproxy.org/t/can-access-one-service-via-haproxy-but-not-others/10072/3 "2024-08-01T13:54:53Z")

</div>

Use different hostnames pointing to Haproxy as opposed to paths like `/service1` , `/service2` and `/service3`.

The reason is that while haproxy can correct the request URI (as you do in the backend with `http-request replace-path`), haproxy cannot replace or rewrite the URI in the HTTP payload (the HTML code) like links to CSS and JS files, etc.

There is an ocean of issues caused by path style content switching, which is why I strongly encourage to use hostnames instead.
