Hi Matt, I'm Ccing the ML since the answer can interest everybody here.
> Thanks for you explanation... I found something indeed on the devel version > yesterday, you can also remove this way I saw ? yes, you can delete content from a map thanks to the socket or through information found in HTTP headers. > What do you mean by filecontents on reload ? I mean that the content of the map is read from a flat file. If you modify running map, HAProxy only updates its memory, not the flat file. So after a reload, if the flat file does not contain same content as HAProxy's memory, then updates are lost. > What I add this was is added to memory and not to the file ? exactly > So, I need to sync the file with the memory in some way ? yes. This can be done easily with a tool since you can dump a map content from HAProxy's socket. Baptiste > > > 2014-05-23 10:17 GMT+02:00 Baptiste <[email protected]>: > >> Hi Matt, >> >> You have to use HAProxy 1.5. >> You can load redirects from a map file. >> Map file content, 2 columns, with on the left the reference (what >> you're looking from in the client request) and on the right the >> response to send back. >> domain2.com subdomain.domain1.com >> >> Then, in your frontend, simply add: >> http-request redirect code 302 prefix >> http://%[req.hdr(host),map_str(map_redirects.lst)] if { >> req.hdr(Host),map_str(map_redirects.lst) -m found } >> >> Content of map_redirects.lst: >> domain2.com subdomain.domain1.com >> >> If the domain is not listed, then HAProxy will return a 503. >> >> Here are some results: >> GET http://127.0.0.1:8080/ -H "Host: domain2.com" >> >> HTTP/1.1 302 Found >> Cache-Control: no-cache >> Content-length: 0 >> Location: http://subdomain.domain1.com/ >> Connection: close >> >> >> GET http://127.0.0.1:8080/blah -H "Host: domain2.com" >> >> HTTP/1.1 302 Found >> Cache-Control: no-cache >> Content-length: 0 >> Location: http://subdomain.domain1.com/blah >> Connection: close >> >> >> >> GET http://127.0.0.1:8080/ -H "Host: domain1.com" >> >> HTTP/1.0 503 Service Unavailable >> Cache-Control: no-cache >> Connection: close >> Content-Type: text/html >> >> >> >> >> The content of the map can be updated through the HAProxy socket or >> though HTTP headers. >> Read the manual to know how. >> >> Bear in mind HAProxy will reset its memory with the content of the >> file when reloading. So it's up to you to sync the memory of HAProxy >> and the content of the file. >> >> Baptiste >> >> >> On Thu, May 22, 2014 at 11:08 PM, Matt . <[email protected]> wrote: >> > Babtiste, >> > >> > I'm not able to find any solution to add such rewrites, am I looking >> > wrong ? >> > >> > Cheers, >> > >> > Matt >> > >> > >> > 2014-05-22 16:37 GMT+02:00 Matt . <[email protected]>: >> > >> >> Hi, >> >> >> >> That is nice, is that in the development version ? I didn't see it in >> >> 1.4 >> >> as I'm right. >> >> >> >> I need to forward domain2.com to subdomain.domain1.com >> >> >> >> and subdomain.domain1.com may be a various of webservers that serve >> >> that >> >> content. >> >> >> >> Thanks! >> >> >> >> Matt >> > >> > > >

