Reverse Proxy for Wordpress blog

Topics: User Forum
Dec 18, 2011 at 11:10 PM


Can someone please help me with setting up a reverse proxy for my wordpress blog? 

Everything seems to work, however I am not seeing the new header in the resulting page.

Here is my code:

RewriteLog D:\FTP\my-main-www-domain\ISAPI_Rewriter.Log\iirfLog.out 
RewriteLogLevel 0
MaxMatchCount 10
StatusInquiry ON /awiirfStatus RemoteOk
RewriteEngine ON

RedirectRule ^/testblog$ /testblog/ [I]
ProxyPass ^/testblog/(.*)$$1
ProxyPassReverse /testblog
rewriteCond $1 ^(testblog)$ [I]
RewriteHeader X-WPE-Rewrite ^$ [L]

Thank you

Dec 22, 2011 at 5:39 PM

What does it mean when you say, "I am not seeing the new header in the resulting page."?

When a ProxyPass rule fires within IIRF immediately transfers control. No further rules are evaluated. This means if you have a RewriteHeader rule that follows a ProxyPass rule, it is possible that the RewriteHeader rule will never fire. It could be that is what is happening in your case.


Jan 3, 2012 at 1:16 AM

Does this mean if I move the following code before the ProxyPass call, I should be able to see the header being written to the output?

rewriteCond $1 ^(testblog)$ [I]
RewriteHeader X-WPE-Rewrite ^$ [L]

Is my formatting correct?

Jan 4, 2012 at 4:36 AM

Looks basically right.

Except you use $1 in the RewriteCond and in fact there is no $1. The $1 is a back-reference that refers to the 1st captured subgroup resulting from applying the rule. The rule, in this case a RewriteHeader rule, applies a regex to the header and populates the captured subgroup array, one capture for each pair of parens in the regex. But you have no parens in the regex.

You need to review the documentation!




Jan 10, 2012 at 12:18 AM


Please forgive me for my ignorance but are the rewritten headers only visible through server variables or is there a way to actually change the response headers so that my new custom header is in there?

For example, I have setup a web page where I am rewriting the header but I don't see it in the response header. I do see the rewritten header when I call Response.write Request.ServerVariables("ALL_HTTP").

Jan 10, 2012 at 10:50 PM

This is a common confusion.

The rewriting engine (IIRF) rewrites requests.  So the headers that get modified are request headers. If you want to set response headers, you need to do that in the application that formulates the response. That's usually not IIRF.  In some cases the response is sent directly from IIRF - for example when you use a NF or F modifier on a rule, which causes a 404 Not Found or a 401 Forbidden response.   But those cases are not actually rewrites. Confusing, yes.

If you use IIRF to rewrite a request, you are merely modifying the request. That happens well before any response is created, and so, in the normal case, IIRF cannot and does not affect the response headers that get generated and sent back.