Haproxy configuration problem


#1

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 10.200.80.96, while if the request is http://sowinproxy/blog the requests must be redirected to the 10.200.80.97 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 10.200.80.97 check

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

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


#2

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

acl is_blog path_beg /blog/


#3

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


#4

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

acl is_blog path_beg /blog


#5

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


#6

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.


#7

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


#8

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.


#9

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


#10

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 …


#11

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