Re: http-request redirect prefix, substituting *only* the hostname without port

2014-11-20 Thread Scott Severtson
Perfect! I figured there was a way to accomplish this, but I hadn't thought
about manipulating the headers.
Thanks!

--Scott

On Thu, Nov 20, 2014 at 11:17 AM, Baptiste bed...@gmail.com wrote:

 On Thu, Nov 20, 2014 at 4:39 PM, Scott Severtson
 ssevert...@digitalmeasures.com wrote:
  I've read the manual and searched extensively on this, but I seem to be
  missing something. How can I substitute just the requested *hostname*
  (excluding a non-standard port) in a redirect? I tried:
 
  http-request redirect prefix http://%[hdr(host)].example.com code 301
 
 
  However, this preserves the non-standard port number if specified in the
  request, resulting in something like:
 
  Request:
  GET / HTTP/1.1
  Host: original-hostname.com:81
 
  Response:
  HTTP/1.1 301 Moved Permanently
  Location: http://original-hostname.com:81.example.com/
 
  I'll have a fairly sizeable and dynamic lists of hosts, so adding
 explicit
  per-host ACLs/redirects is not desired.
 
  Is there any way to strip the requested port from the host header? Is
 there
  any other way to substitute just the requested hostname?
 
  Thanks!
  --Scott


 Hi Scott,

 You can try to strip it before generating the rewrite:
 http-request replace-value Host (.*):.* \1 if { hdr_sub(Host) : }
 http-request redirect prefix http://%[hdr(host)].example.com code 301

 Baptiste



Re: http-request redirect prefix, substituting *only* the hostname without port

2014-11-20 Thread Baptiste
On Thu, Nov 20, 2014 at 5:35 PM, Scott Severtson
ssevert...@digitalmeasures.com wrote:
 Perfect! I figured there was a way to accomplish this, but I hadn't thought
 about manipulating the headers.
 Thanks!

 --Scott


Actually, the http-request rules should be like a firewall ruleset.
They are processed in the same way they written. So next rule benefit
from processing of previous one.

Baptiste