Re: could haproxy call redis for a result?
nginx would be more suitable for something like this. It even has a redis plugin: http://wiki.nginx.org/HttpRedis Perhaps you can achieve your functionality with the redis_next_upstream parameter. Sergej On Tue, May 8, 2012 at 4:39 AM, S Ahmed sahmed1...@gmail.com wrote: I agree it will add overheard for each call. Well would there a way for me to somehow tell haproxy from my application to block a particular url, and then send another api call to allow traffic from that url? That would be really cool to have an API where I could do this from. I know haproxy has rate limiting as per: http://blog.serverfault.com/2010/08/26/1016491873/ But wondering if one could have more control over it, like say you have multiple haproxy servers and you want to synch them, or simply the application layer needs to decide when to drop a url connection or when to accept. On Mon, May 7, 2012 at 7:39 PM, Baptiste bed...@gmail.com wrote: On Tue, May 8, 2012 at 12:26 AM, S Ahmed sahmed1...@gmail.com wrote: I'm sure this isn't possible but it would be cool if it is. My backend services write to redis, and if a client reaches a certain threshold, I want to hard drop all further requests until x minutes have passed. Would it be possible, for each request, haproxy performs a lookup in redis, and if a 0 is returned, drop the request completly (hard drop), if it is 1, continue processing. It would introduce latency in the request processing. Why would you need such way of serving your request? By the way, this is not doable with HAProxy. Well, at least, not out of the box :) Depending on your needs, you could hack some dirty scripts which can sync your redis DB with HAProxy server status through the stats socket. cheers
req_proto_http does not work
hello, This configuration will always send to backend tcpback, if I run curl http://127.0.0.1 frontend tcpfront *:80 acl acl_ishttp req_proto_http use_backend nginx if acl_ishttp default_backend tcpback The string that curl sends is GET / HTTP/1.1\r\nUser-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3\r\nHost: 127.0.0.1\r\nAccept: */*\r\n\r\n Is there something wrong with req_proto_http or my configuration? thank you, Sergej
Re: req_proto_http does not work
On Thu, Jun 10, 2010 at 8:45 PM, Willy Tarreau w...@1wt.eu wrote: On Thu, Jun 10, 2010 at 06:39:09PM +0200, Rapsey wrote: hello, This configuration will always send to backend tcpback, if I run curl http://127.0.0.1 frontend tcpfront *:80 acl acl_ishttp req_proto_http use_backend nginx if acl_ishttp default_backend tcpback The string that curl sends is GET / HTTP/1.1\r\nUser-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3\r\nHost: 127.0.0.1\r\nAccept: */*\r\n\r\n Is there something wrong with req_proto_http or my configuration? yes, you forgot to indicate how long you want to wait for an HTTP request to come in, so basically as soon as a client connects, your rules are evaluated, protocol is not http (since the buffer is empty) and your rule is not matched. Generally, waiting at most 3-5 seconds is far more than enough. For this, just do the following : frontend tcpfront *:80 tcp-request inspect-delay 5s tcp-request content accept if HTTP use_backend nginx if HTTP default_backend tcpback Regards, Willy It works. Thank you. Sergej
Re: layer 7 proxy hierarchy
You can't do this with haproxy, but you can with nginx and X-Accel-Redirect Sergej On Wed, Jun 9, 2010 at 5:17 AM, Jonah Benton jo...@jonah.com wrote: Greetings, I have several web applications that each service different portions of the same taxonomy. The taxonomy is very deep- millions of resources- and the rules that dictate which part of the taxonomy each application serves are fluid and changing. In general it isn't easy to determine declaratively which web application should service which uri. I'd like to set up a proxy dispatch hierarchy, such that requests arriving at a proxy front end would be dispatched to one of the web applications. The response from web application 1 would checked by the proxy front end. If it's a 404, then the front end discards the response from web application 1, and dispatches to the next web application. If non-404, then the response is returned to the client and the transaction is considered handled. A 404 response from the last web application would be considered a true 404 and would get returned to the client. From a quick look at the configuration, it doesn't appear that this can be done with HAProxy (nor with any other proxy software I've looked at). Am I wrong, can this be arranged? Please cc me, I'm not subscribed to the list. Thank you, Jonah
Re: layer 7 proxy hierarchy
I use it to dispatch to another app. As for ordering, I think you would need to do it from the app if I understand your use case correctly. Sergej On Wed, Jun 9, 2010 at 5:38 PM, Jonah Benton jo...@jonah.com wrote: Thanks for the rapid response. At first blush, X-Accel-Redirect doesn't look to be quite what I need: * it appears that the specific use case is to dispatch to optimized static file delivery; it's not clear whether the dispatched-to-back-end can be another app, rather than something that can be delivered with sendfile() * assuming the dispatched-to-backend can be another app, can apps arbitrarily chain themselves together with a series of X-Accel-Redirect responses, or does nginx impose some sort of limit * if apps can arbitrarily chain themselves together, this still means I need to maintain the app ordering in the webapp rather than in the proxy. The webapps are java, so this will be a little tricky, and the chaining appears to have to be by path, which would be proxy-only knowledge. So, maybe it's doable, though I'd rather be able to just maintain the ordering in the proxy configuration. I'll look some more, though, thank you for the pointer. On Wed, Jun 9, 2010 at 2:58 AM, Rapsey rap...@gmail.com wrote: You can't do this with haproxy, but you can with nginx and X-Accel-Redirect Sergej On Wed, Jun 9, 2010 at 5:17 AM, Jonah Benton jo...@jonah.com wrote: Greetings, I have several web applications that each service different portions of the same taxonomy. The taxonomy is very deep- millions of resources- and the rules that dictate which part of the taxonomy each application serves are fluid and changing. In general it isn't easy to determine declaratively which web application should service which uri. I'd like to set up a proxy dispatch hierarchy, such that requests arriving at a proxy front end would be dispatched to one of the web applications. The response from web application 1 would checked by the proxy front end. If it's a 404, then the front end discards the response from web application 1, and dispatches to the next web application. If non-404, then the response is returned to the client and the transaction is considered handled. A 404 response from the last web application would be considered a true 404 and would get returned to the client. From a quick look at the configuration, it doesn't appear that this can be done with HAProxy (nor with any other proxy software I've looked at). Am I wrong, can this be arranged? Please cc me, I'm not subscribed to the list. Thank you, Jonah
Re: make on os x
Yes thank you. I figured it out eventually and used the same command as you wrote to build, but kqueue was still not getting enabled. This is the make command I eventually figured out works without issues (uses the default Makefile): make TARGET=osx CPU=i686 USE_KQUEUE=1 USE_POLL=1 USE_PCRE=1 Tested it on darwin and leopard and I haven't noticed any problems. Sergej On Thu, Jul 23, 2009 at 7:17 AM, Willy Tarreau w...@1wt.eu wrote: Hi, On Thu, Jun 11, 2009 at 09:51:00AM +0200, Rapsey wrote: Sorry error in -vv output, TARGET = darwin Sergej On Thu, Jun 11, 2009 at 9:46 AM, Rapsey rap...@gmail.com wrote: I'm trying to build haproxy with kqueue on osx leopard, but I don't think it's working. There is no mention of DENABLE_KQUEUE anywhere when it's building it. This is the make I use: make Makefile.osx TARGET=darwin CPU=i686 USE_PCRE=1 all Ok you're not using the proper syntax, you need to use : make -f Makefile.osx TARGET=darwin CPU=i686 USE_PCRE=1 all Otherwise you tell make to build Makefile.osx, which already exists so no error is reported. Also, please don't use 1.3.17 as it has a nasty bug which can be triggered on 64-bit systems. Willy
Re: make on os x
Even with darwin kqueue was not enabled, I tried it. Why is there even a separate osx makefile if the default one works? Sergej On Thu, Jul 23, 2009 at 1:20 PM, Willy Tarreau w...@1wt.eu wrote: On Thu, Jul 23, 2009 at 08:40:23AM +0200, Rapsey wrote: Yes thank you. I figured it out eventually and used the same command as you wrote to build, but kqueue was still not getting enabled. This is the make command I eventually figured out works without issues (uses the default Makefile): make TARGET=osx CPU=i686 USE_KQUEUE=1 USE_POLL=1 USE_PCRE=1 you're right, I wrote osx because you did, but it's TARGET=darwin which automatically enables KQUEUE. Maybe we should simplify this makefile since it only supports one OS. Regards, Willy
no trailing slash results in 301
http://somewebaddress/test will result in a 301 to the server for which haproxy should be proxying requests. So the user is redirected to http://localhost:8080/test. http://somewebaddress/test/ works fine. I tried backend nginx and apache and it is the same. Anyone have an idea whats going on? My haproxy config: global maxconn 1 pidfile /tmp/haproxy.pid defaults contimeout 5000 clitimeout 5 srvtimeout 5 frontend httpfront *:80 mode http option forwardfor acl acl_str path_end .str use_backend someservice if acl_str default_backend nginx backend someservice mode http option httpclose server strserver 127.0.0.1:6002 backend nginx mode http option httpclose server nginxsrv 127.0.0.1:8080 thank you Sergej
Re: no trailing slash results in 301
Oh it's not a haproxy issue but a webserver one. Because it detects a directory at that location, it will redirect back to itself, with the same URL and add a trailing slash. Unfortunately the server is at 8080 and it will add that port also. Sergej On Thu, Jul 23, 2009 at 4:39 PM, Rapsey rap...@gmail.com wrote: http://somewebaddress/test will result in a 301 to the server for which haproxy should be proxying requests. So the user is redirected to http://localhost:8080/test. http://somewebaddress/test/ works fine. I tried backend nginx and apache and it is the same. Anyone have an idea whats going on? My haproxy config: global maxconn 1 pidfile /tmp/haproxy.pid defaults contimeout 5000 clitimeout 5 srvtimeout 5 frontend httpfront *:80 mode http option forwardfor acl acl_str path_end .str use_backend someservice if acl_str default_backend nginx backend someservice mode http option httpclose server strserver 127.0.0.1:6002 backend nginx mode http option httpclose server nginxsrv 127.0.0.1:8080 thank you Sergej
make on os x
I'm trying to build haproxy with kqueue on osx leopard, but I don't think it's working. There is no mention of DENABLE_KQUEUE anywhere when it's building it. This is the make I use: make Makefile.osx TARGET=darwin CPU=i686 USE_PCRE=1 all checking the executable after make: ./haproxy -vv HA-Proxy version 1.3.17 2009/03/29 Copyright 2000-2008 Willy Tarreau w...@1wt.eu Build options : TARGET = osx CPU = i686 CC = gcc CFLAGS = -O2 -march=i686 -g OPTIONS = USE_PCRE=1 So how do I enable kqueue in the build? thank you, Sergej