Re: Configuring different backends using ACL

2013-06-20 Thread Ahmed H.
I see, you are right. When I do a curl -I, I see that the logs match the
output of the curl /jboss.

Thanks again for clarifying how this works, I really appreciate that :)


On Thu, Jun 20, 2013 at 2:32 PM, Lukas Tribus  wrote:

> Hi Ahmed,
>
> > I am not sure if it does switch to the immutant backend but it doesn't
> > seem that way from the debug mode.
>
> In the curl -I output you see the server header, you can the compare them
> with what haproxy sent:
> Server: Apache/2.2.21 (Unix) mod_cluster/1.2.0.Final mod_ssl/2.2.21
> OpenSSL/0.9.8r DAV/2 mod_jk/1.2.30
>
> Obviously if all 3 severs have the exact same server value, then this isn't
> helpful.
>
>
> Regards,
>
> Lukas


RE: Configuring different backends using ACL

2013-06-20 Thread Lukas Tribus
Hi Ahmed,

> I am not sure if it does switch to the immutant backend but it doesn't
> seem that way from the debug mode.

In the curl -I output you see the server header, you can the compare them
with what haproxy sent:
Server: Apache/2.2.21 (Unix) mod_cluster/1.2.0.Final mod_ssl/2.2.21 
OpenSSL/0.9.8r DAV/2 mod_jk/1.2.30

Obviously if all 3 severs have the exact same server value, then this isn't
helpful.


Regards,

Lukas 


Re: Configuring different backends using ACL

2013-06-20 Thread Ahmed H.
Thanks for the clarification Lukas.

I will have to do some work on the backend servers to accommodate for that.

I am not sure if it does switch to the immutant backend but it doesn't seem
that way from the debug mode. However, I might be missing something (I'm
still new to this)...

Thanks


On Thu, Jun 20, 2013 at 1:16 PM, Lukas Tribus  wrote:

> Hi!
>
>
> > There is no actual /jboss directory on any webserver, so all the curl
> > commands would result in a not found error. It seems like I didn't
> > quite understand how haproxy handles the backend forwarding.
>
>
> Well, haproxy does not strip /jboss if thats what you mean. However,
> it should switch to the "immutant" backend, and not the server1 or 2.
>
> So it does correctly switch to that backend, it just returns 404 because
> /jboss doesn't exist, correct? Then haproxy behaves as expected, yes.
>
>
>
> Regards,
>
> Lukas


RE: Configuring different backends using ACL

2013-06-20 Thread Lukas Tribus
Hi!


> There is no actual /jboss directory on any webserver, so all the curl  
> commands would result in a not found error. It seems like I didn't  
> quite understand how haproxy handles the backend forwarding. 


Well, haproxy does not strip /jboss if thats what you mean. However,
it should switch to the "immutant" backend, and not the server1 or 2.

So it does correctly switch to that backend, it just returns 404 because
/jboss doesn't exist, correct? Then haproxy behaves as expected, yes.



Regards,

Lukas 


Re: Configuring different backends using ACL

2013-06-20 Thread Ahmed H.
Ah, now I think I see where you are going with this.

I do not have anything on any server that ends in /jboss. The whole thing
about having /jboss was simply for haproxy. What I was expecting is haproxy
gets a request that has /jboss in it, and it would think "this user wants
the jboss cluster", and proceeds to forward the user to http://
/

There is no actual /jboss directory on any webserver, so all the curl
commands would result in a not found error. It seems like I didn't quite
understand how haproxy handles the backend forwarding.


On Thu, Jun 20, 2013 at 12:46 PM, Lukas Tribus  wrote:

> Hi Ahmed,
>
> Are you sure server1 is the backend responding? Can you post the
> output of:
> curl -I http:///jboss
> curl -I http:///jboss
> curl -I http:///jboss
> curl -I http:///jboss
>
>
> can you clear the cookies in your browser and retry? This should
> *not* fix the issue in my opinion, but please try.
>
>
>
> Regards,
>
> Lukas


RE: Configuring different backends using ACL

2013-06-20 Thread Lukas Tribus
Hi Ahmed,

Are you sure server1 is the backend responding? Can you post the
output of:
curl -I http:///jboss
curl -I http:///jboss
curl -I http:///jboss
curl -I http:///jboss


can you clear the cookies in your browser and retry? This should
*not* fix the issue in my opinion, but please try.



Regards,

Lukas 


Re: Configuring different backends using ACL

2013-06-20 Thread Ahmed H.
Hello Lukas,

Here is the updated config file. I added http-server-close to the default:

global
daemon
maxconn 500

defaults
mode http
balance roundrobin
timeout connect 1ms
timeout server 5ms
timeout client  5000
option http-server-close


frontend http-in
bind localhost:80

acl is_webapp path_beg /webapp
acl is_jboss path_beg /jboss

use_backend webapp if is_webapp
use_backend jboss if is_jboss

default_backend webapp

backend webapp
  balance roundrobin
  cookie SERVERID insert indirect nocache
  server server1 x.x.x.x/webapp maxconn 500 check cookie s1
  server server2 x.x.x.x/webapp maxconn 500 check cookie s2

backend jboss
  balance roundrobin
  server immutant x.x.x.x/demo check

listen admin
  bind *:8080
  stats enable



And the log output when I try http://localhost/jboss:

0006:http-in.accept(0004)=0007 from [127.0.0.1:49514]
0006:http-in.clireq[0007:]: GET /jboss HTTP/1.1
0006:http-in.clihdr[0007:]: Host: localhost
0006:http-in.clihdr[0007:]: User-Agent: Mozilla/5.0 (Macintosh;
Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko)
Version/6.0.4 Safari/536.29.13
0006:http-in.clihdr[0007:]: Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
0006:http-in.clihdr[0007:]: Cache-Control: max-age=0
0006:http-in.clihdr[0007:]: Accept-Language: en-us
0006:http-in.clihdr[0007:]: Accept-Encoding: gzip, deflate
0006:http-in.clihdr[0007:]: Cookie:
_sin_session=804eaea9e0f55a666249e69be79b7585; SERVERID=server1
0006:http-in.clihdr[0007:]: Connection: keep-alive
0006:jboss.srvrep[0007:0008]: HTTP/1.1 404 Not Found
0006:jboss.srvhdr[0007:0008]: Date: Wed, 19 Jun 2013 23:10:22 GMT
0006:jboss.srvhdr[0007:0008]: Server: Apache/2.2.21 (Unix)
mod_cluster/1.2.0.Final mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 mod_jk/1.2.30
0006:jboss.srvhdr[0007:0008]: Content-Length: 203
0006:jboss.srvhdr[0007:0008]: Connection: close
0006:jboss.srvhdr[0007:0008]: Content-Type: text/html;
charset=iso-8859-1
0006:http-in.clicls[0007:]
0006:http-in.closed[0007:]


It seems to be going to server1 of the webapp backend. I believe it might
be following the default backend in this case.


On Thu, Jun 20, 2013 at 10:15 AM, Lukas Tribus  wrote:

> Hi Ahmed,
>
> you are in tunneling mode, only the first request will be inspected!
>
>
> Please configure "option http-server-close" or "option httpclose":
>
>
> http://cbonte.github.io/haproxy-dconv/configuration-1.4.html#option%20http-server-close
>
> http://cbonte.github.io/haproxy-dconv/configuration-1.4.html#option%20httpclose
>
>
> If its still not working, start haproxy in debug mode (./haproxy -d) and
> post
> the debug output of the failed request.
>
>
> Lukas


RE: Configuring different backends using ACL

2013-06-20 Thread Lukas Tribus
Hi Ahmed,

you are in tunneling mode, only the first request will be inspected!


Please configure "option http-server-close" or "option httpclose":

http://cbonte.github.io/haproxy-dconv/configuration-1.4.html#option%20http-server-close
http://cbonte.github.io/haproxy-dconv/configuration-1.4.html#option%20httpclose


If its still not working, start haproxy in debug mode (./haproxy -d) and post
the debug output of the failed request.


Lukas 


Re: Configuring different backends using ACL

2013-06-20 Thread Ahmed H.
Hello,

Here is the full config file. I redacted the IP addresses:

global
daemon
maxconn 500

defaults
mode http
balance roundrobin
timeout connect 1ms
timeout client 5ms
timeout server 5ms

frontend http-in
bind localhost:80

acl is_webapp path_beg /webapp
acl is_jboss path_beg /jboss

use_backend webapp if is_webapp
use_backend jboss if is_jboss

backend webapp
  balance roundrobin
  cookie SERVERID insert indirect nocache
  server server1 x.x.x.x/webapp maxconn 500 check cookie s1
  server server2 x.x.x.x/webapp maxconn 500 check cookie s2

backend jboss
  balance roundrobin
  server immutant x.x.x.x/demo check

listen admin
  bind *:8080
  stats enable

PiBa-NL, to answer your question, yes, I get the same error if I go to
jbossserver/jboss. What I was trying to do is if I go to
http://haproxy/jboss, it forwards me to http://jbossserver/demo, and if I
go to http://haproxy/webapp, it would take me to http://webappserver/

Now that you mentioned it, I think I am just not understanding how it all
ties in. What would I need to do to get it to work this way. Is it possible
to achieve this without modifying the apps that are deployed in the backend?

Regards,

Ahmed


On Wed, Jun 19, 2013 at 5:49 PM, PiBa-NL  wrote:

> Hi Ahmed,
> small question/clarification request.
> what happens when you directly browse to the jboss backend? like this
> http://jbosserver/jboss/ do you get this same "not found" ?
>
> So haproxy is then forwarding the request like it should, but what i think
> you want is that haproxy will forward a request to
> http://haproxy/jboss/index.**html  to
> http://jbossserver/index.html , is that indeed what you want/expect? im
> not sure thats actually possible.. (also thinking about links send in a
> response would not point to the subfolder.)
>
> greets PiBa-NL
> Op 19-6-2013 23:26, Lukas Tribus schreef:
>
>  Hi Ahmed!
>>
>>
>>  Any suggestions?
>>>
>> Post the complete configuration, inlcuding default, global and all backend
>> sections (checking mode http, httpclose, etc). If that doesn't lead to any
>> conclusion, we will need you to start haproxy in debug mode, capture the
>> request and post it on the list, so we can confront it with the
>> configuration.
>>
>>
>> Regards,
>>
>> Lukas
>>
>
>


Re: Configuring different backends using ACL

2013-06-19 Thread PiBa-NL

Hi Ahmed,
small question/clarification request.
what happens when you directly browse to the jboss backend? like this  
http://jbosserver/jboss/ do you get this same "not found" ?


So haproxy is then forwarding the request like it should, but what i 
think you want is that haproxy will forward a request to 
http://haproxy/jboss/index.html to http://jbossserver/index.html , is 
that indeed what you want/expect? im not sure thats actually possible.. 
(also thinking about links send in a response would not point to the 
subfolder.)


greets PiBa-NL
Op 19-6-2013 23:26, Lukas Tribus schreef:

Hi Ahmed!



Any suggestions?

Post the complete configuration, inlcuding default, global and all backend
sections (checking mode http, httpclose, etc). If that doesn't lead to any
conclusion, we will need you to start haproxy in debug mode, capture the
request and post it on the list, so we can confront it with the
configuration.


Regards,

Lukas   





RE: Configuring different backends using ACL

2013-06-19 Thread Lukas Tribus
Hi Ahmed!


> Any suggestions?

Post the complete configuration, inlcuding default, global and all backend
sections (checking mode http, httpclose, etc). If that doesn't lead to any
conclusion, we will need you to start haproxy in debug mode, capture the
request and post it on the list, so we can confront it with the
configuration.


Regards,

Lukas 


Re: Configuring different backends using ACL

2013-06-19 Thread Ahmed H.
Hello,

I tried your suggestion and I am still getting a "not found" error in my
browser. It doesn't seem to map "localhost/jboss" to anything for example.
Just to be clear, I do not have any apps of any sort in localhost/jboss, it
is just waht I put in the settings. I assumed that haproxy will still read
that somehow. I think that's where I am stuck, or maybe I missed a step.
Any suggestions?

Note: I did not define a default backend (purposely).

Thanks


On Wed, Jun 19, 2013 at 4:04 PM, Nenad Merdanovic  wrote:

> I am obviously missing a slash in the inline ACL example, should be:
>
> use_backend webapp if { path_beg /webapp }
>
> On 06/19/2013 10:01 PM, Nenad Merdanovic wrote:
> > Hello Ahmed,
> >
> > Use path_beg instead of url_beg.
> >
> > Also, naming should be changed as this is very unclear:
> >
> >> frontend http-in
> >> bind localhost:80
> >>
> >> acl is_webapp path_beg /webapp
> >> acl is_jboss path_beg /jboss
> >>
> >> use_backend webapp if is_webapp
> >> use_backend jboss if is_jboss
> >
> > Or even use inline ACLs:
> > use_backend webapp if { path_beg webapp }
> >
> > This is how I usually do it, but it all comes down to a person's
> preference.
> >
> > Regards,
> > Nenad
> >
> > On 06/19/2013 09:46 PM, Ahmed H. wrote:
> >> Hello,
> >>
> >> I found a few examples of this but can't get it to work locally. I have
> >> a local haproxy running on port 80, and I was able to get it to work
> >> with one backend defined. If I open the browser and type "localhost" it
> >> routes me to one of the servers defined in my single backend.
> >>
> >> Now I want to define two backends. Basically I'll have a backend for a
> >> regular web app and one that hosts JBoss apps. How can route the
> >> requests based on the URL I enter? What I tried is the following:
> >>
> >> frontend http-in
> >> bind localhost:80
> >>
> >> acl webapp url_beg /webapp
> >> acl jboss url_beg /jboss
> >>
> >> use_backend webapp if webapp
> >> use_backend jboss if jboss
> >>
> >> Not shown here are the proper backends.
> >>
> >> What I was trying to do was that if i entered "localhost/webapp" in the
> >> browser, it would take me to the webapp backends, and if I entered
> >> "localhost/jboss" it would take me to the jboss backends. That of course
> >> does not work, and I get a "Not found" error.
> >>
> >> How can I achieve what I want to do? Do I have to create something on a
> >> web server? Am I not using the ACL properly?
> >>
> >> Thanks!
> >
>
> --
> Nenad Merdanovic | PGP: 0x423edcb2 | Web: http://nimzo.info
> Linkedin: http://www.linkedin.com/in/nenadmerdanovic
>


Re: Configuring different backends using ACL

2013-06-19 Thread Nenad Merdanovic
I am obviously missing a slash in the inline ACL example, should be:

use_backend webapp if { path_beg /webapp }

On 06/19/2013 10:01 PM, Nenad Merdanovic wrote:
> Hello Ahmed,
> 
> Use path_beg instead of url_beg.
> 
> Also, naming should be changed as this is very unclear:
> 
>> frontend http-in
>> bind localhost:80
>>
>> acl is_webapp path_beg /webapp
>> acl is_jboss path_beg /jboss
>>
>> use_backend webapp if is_webapp
>> use_backend jboss if is_jboss
> 
> Or even use inline ACLs:
> use_backend webapp if { path_beg webapp }
> 
> This is how I usually do it, but it all comes down to a person's preference.
> 
> Regards,
> Nenad
> 
> On 06/19/2013 09:46 PM, Ahmed H. wrote:
>> Hello,
>>
>> I found a few examples of this but can't get it to work locally. I have
>> a local haproxy running on port 80, and I was able to get it to work
>> with one backend defined. If I open the browser and type "localhost" it
>> routes me to one of the servers defined in my single backend.
>>
>> Now I want to define two backends. Basically I'll have a backend for a
>> regular web app and one that hosts JBoss apps. How can route the
>> requests based on the URL I enter? What I tried is the following:
>>
>> frontend http-in
>> bind localhost:80
>>
>> acl webapp url_beg /webapp
>> acl jboss url_beg /jboss
>>
>> use_backend webapp if webapp
>> use_backend jboss if jboss
>>
>> Not shown here are the proper backends.
>>
>> What I was trying to do was that if i entered "localhost/webapp" in the
>> browser, it would take me to the webapp backends, and if I entered
>> "localhost/jboss" it would take me to the jboss backends. That of course
>> does not work, and I get a "Not found" error.
>>
>> How can I achieve what I want to do? Do I have to create something on a
>> web server? Am I not using the ACL properly?
>>
>> Thanks!
> 

-- 
Nenad Merdanovic | PGP: 0x423edcb2 | Web: http://nimzo.info
Linkedin: http://www.linkedin.com/in/nenadmerdanovic



Re: Configuring different backends using ACL

2013-06-19 Thread Nenad Merdanovic
Hello Ahmed,

Use path_beg instead of url_beg.

Also, naming should be changed as this is very unclear:

> frontend http-in
> bind localhost:80
>
> acl is_webapp path_beg /webapp
> acl is_jboss path_beg /jboss
>
> use_backend webapp if is_webapp
> use_backend jboss if is_jboss

Or even use inline ACLs:
use_backend webapp if { path_beg webapp }

This is how I usually do it, but it all comes down to a person's preference.

Regards,
Nenad

On 06/19/2013 09:46 PM, Ahmed H. wrote:
> Hello,
> 
> I found a few examples of this but can't get it to work locally. I have
> a local haproxy running on port 80, and I was able to get it to work
> with one backend defined. If I open the browser and type "localhost" it
> routes me to one of the servers defined in my single backend.
> 
> Now I want to define two backends. Basically I'll have a backend for a
> regular web app and one that hosts JBoss apps. How can route the
> requests based on the URL I enter? What I tried is the following:
> 
> frontend http-in
> bind localhost:80
> 
> acl webapp url_beg /webapp
> acl jboss url_beg /jboss
> 
> use_backend webapp if webapp
> use_backend jboss if jboss
> 
> Not shown here are the proper backends.
> 
> What I was trying to do was that if i entered "localhost/webapp" in the
> browser, it would take me to the webapp backends, and if I entered
> "localhost/jboss" it would take me to the jboss backends. That of course
> does not work, and I get a "Not found" error.
> 
> How can I achieve what I want to do? Do I have to create something on a
> web server? Am I not using the ACL properly?
> 
> Thanks!

-- 
Nenad Merdanovic | PGP: 0x423edcb2 | Web: http://nimzo.info
Linkedin: http://www.linkedin.com/in/nenadmerdanovic