Is there a way to allow only URLs in a given format in haproxy? I would like to allow connections only if the address contains a specific suffix (in my case .png or .jpg or .gif) and reject it with a 404 if not.
Does Haproxy allows regexp?
like:
(myurl).*\.(png|jpg|gif)
You should be able to do this with a test of path_reg
.
http-request deny unless { path_reg \.(png|jpg|gif)$ }
Or, simply with literal string matches in a named ACL. If any rule in a named ACL matches, the ACL matches.
acl path_ok path_end .gif
acl path_ok path_end .jpg
acl path_ok path_end .png
http-request deny unless path_ok