Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Http header rewrite issue

Hello!

Is it possible to perform a header rewrite on a webhost-redirect? I perform a redirect to an URL, so far so good. The customer wants this redirect to be invisible, meaning that the redirected request is transparent. Below I try to do this via an action-list, I'm trying to swap the header used for the redirect-server to an general header name. See below for the configuration.

action-list type modify http REWRITE

header rewrite response Host header-value "http://sefags155:7001/" replace "http://enoviaprod/"
header rewrite response Host header-value "http://sefags154:7001/" replace "http://enoviaprod/"

1 REPLY

Re: Http header rewrite issue

Hi Hborg,


Here is the correct way to do it:

You can rewrite an HTTP header in request packets from a client, response packets from a server, or both, by using the header rewrite command in

action list modify configuration mode. The syntax of this command is as follows:

header rewrite {request | response | both} header_name header-value expression replace pattern

So In your case


action-list type modify http RewriteHost

  header rewrite response Host header-value "sefags(.*)" replace "enoviaprod%1"


Be aware that does not redirect the user to enoviaprod. It just forwards the request to the sefags server with the host field rewritten in the http header.


If you want a redirect to a different server, you need to create a redirect service which will send a 302 redirect to the client forcing a new

connection to be open to enoviaprod....

If you want to retain the hostname & Path in user's Http request then %h (for host) & (%p for path) can be used.

There is a known defect related to the Location filed.  If this is not spelled exactly like above, we don't catch it.

It might then be necessary to do your own rule to catch the exact field header sent by your server and do your own rewrite.


CSCsu01728

ACE: Regex: HTTP header field name should be case insensitive


Workaround:


Configure a header replace function that will match exactly the field name sent by the server.

ie:


header rewrite response location header-value "http://sefags(.*)"  replace  "http://enoviaprod%1"

You need to know, that ACE is performing header rewrite just for the first HTTP request or response.

To do rewriting for each request(response) you should use "header modify per-request" in HTTP parameter map,

and attach that parameter map to needed class in global policy.


parameter-map type http RewriteHost

    header modify per-request


action-list type modify http RewriteHost

    header rewrite response location header-value "http://sefags(.*)"  replace  "http://enoviaprod%1"

Still you can get back to me for any further discusion.

Sachin Garg

1459
Views
0
Helpful
1
Replies
CreatePlease login to create content