Haproxy configuration problem

I would like to implement a configuration that allows me to redirect requests to two internal web servers. In the case where it is indicated as url http://sowinproxy the requests must be directed to the server, while if the request is http://sowinproxy/blog the requests must be redirected to the server.

frontend http-in
bind :80
acl is_blog path_reg ^/blog/.

use_backend tecadmin_blog if is_blog
default_backend webservers

backend tecadmin_blog
mode http
balance roundrobin
option httpchk
option forwardfor
server web2 check

backend webservers
mode http
balance roundrobin
option httpchk
option forwardfor
server web1 check

The configuration is in the spoiler, but it does not work properly. Can you help me? Thank you

Just use path_beg, no need to go all regex here:

acl is_blog path_beg /blog/

Unfortunately it does not work. I had already tried.If call http://sowinproxy/blog is returned the 404 error message

If /blog is what you need to match than use that:

acl is_blog path_beg /blog

Now it works, but the internal pages are not redirected in the correct way. You can see it at the URL http://web.ct.ingv.it/blog

I think i need to set a base path in redirection

At this point you’d configure your blog backend to let it know it runs under /blog/ instead of /.

With further rewriting on the haproxy level you just further complicating your own setup, so I’d avoid that.

It’s not possible in /blog there is a Joomla website.

Why not?

Joomla: Moving the site among directories/sub-directories

Just adjust the $live_site variable.

You can hack around this in haproxy and cause even more problems, or fix it properly in the application.

I did not know the possibility of doing this operation, if you can give me some more info I will make the change.

Thank you

I already gave you the link pointing to the part of the Joomla documentation talking about this exact change.

I don’t see how I’d be able to give you even more information …

1 Like

I tried the solution you indicated to me, but unfortunately it does not work.
All menu links and all include file don’t have the full path.

I think I should insert the base path in the haproxy rules