Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4849

Config for allowing root path + two other paths, and deny all the other paths

$
0
0

What I want is access to these paths:

  1. /
  2. /somepath1
    3 /somepath2

And show 404 page on all other paths. This is what I have tried, but still path /plaa for example routes to “acl path_root path /” -rule.

Configuration what I have tried:

frontend http_front
    bind *:80

    # ACL to allow access from selected networks
    acl allowed_networks src 192.168.0.0/24 10.0.0.0/24

    # ACL to match the desired paths
    acl path_root path /
    acl path1 path_beg /somepath1
    acl path2 path_beg /somepath2

    # Define the ACL conditions and corresponding actions
    use_backend backend_root if allowed_networks path_root
    use_backend backend1 if allowed_networks path1
    use_backend backend2 if allowed_networks path2
    use_backend backend_default if allowed_networks

backend backend_root
    # Configuration for the root path ("/")

backend backend1
    # Configuration for backend 1 ("/somepath1")

backend backend2
    # Configuration for backend 2 ("/somepath2")

backend backend_default
    # Configuration for the default backend or error page
    errorfile 404 /etc/haproxy/errors/404.html

I have also tried to deny, but with no luck:

  • http-request deny unless path1 or path2 or path_root
  • http-request deny if !path1 or !path2 or !path_root

How can I give 404 response or deny traffic to path like /testing and /prevented, if I don’t separate rule for those paths?

Any help appreciated!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>