I have a WordPress site on IIS 8, let's call it www.mysite.com
, that I need to isolate behind a proxy server (with IIS 10).
What I have done so far is:
- changed
siteurl
andhome
tosite.mysite.com
(to avoid continuos redirect) - added site
www.mysite.com
in new server with reverse proxy tosite.mysite.com
(defined in hosts file as old server ip alias) configured as follow<configuration> <system.webServer> <rewrite> <outboundRules rewriteBeforeCache="true"> <clear /> <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="true"> <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://site.mysite.com/(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="true" /> <action type="Rewrite" value="http{R:1}://www.mysite.com/{R:2}" /> </rule> <rule name="RestoreAcceptEncoding" preCondition="NeedRestoringAcceptEncoding" enabled="true"> <match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="true" /> <action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" /> </rule> <preConditions> <preCondition name="ResponseIsHtml1"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> <preCondition name="NeedRestoringAcceptEncoding"> <add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" /> </preCondition> </preConditions> </outboundRules> <rules> <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" /> <action type="Rewrite" url="https://site.mysite.com/{R:1}" /> <serverVariables> <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" /> <set name="HTTP_ACCEPT_ENCODING" value="" /> </serverVariables> </rule> </rules> </rewrite> </system.webServer> </configuration>
Unfortunately this isn't enough.
Despite the reverse proxy outbound rule, many scripts, css links and images point to site.mysite.com
(which is not exposed to the internet) instead of www.mysite.com
.
Is there a way to fix those links making them refer to www
?
Are there better solutions?
I have never worked with WordPress/PHP and have no knowledge how it builds those urls, so if you need any clarification please be as specific as possible thus I can improve my question.
UPDATE
If I configure
- in isolated server
-
siteurl
andhome
towww.mysite.com
- set
127.0.0.1 www.mysite.com
in hosts file
-
- in exposed server
- IIS 10 site binding
www.mysite.com
with forward rule towww.mysite.com
- set
WORDPRESS_SERVER_IP www.mysite.com
in hosts file
- IIS 10 site binding
I get following IIS error:
Errore HTTP 400.605 - Bad Request The request cannot be routed because it has reached the Max-Forwards limit. The server may be self-referencing itself in request routing topology.