Wordpress behind ARR proxy - JSON request not signed - wordpress

Using IIS ARR I have a reverse proxy to a WP blog hosted elsewhere on a Linux server.
These are the proxy rules:
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/blog/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Reverse proxy to blog" stopProcessing="true">
<match url="^(.*)" />
<serverVariables>
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
<action type="Rewrite" url="http://111.22.33.444/blog/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="Add application prefix" preCondition="IsHTML" stopProcessing="true">
<match filterByTags="A, Form, Img, Link, Script" pattern="^http://111.22.33.444/blog/(.*)" />
<action type="Rewrite" value="https://www.example.com/blog/{R:1}" />
</rule>
<rule name="RestoreAcceptEncoding" preCondition="NeedsRestoringAcceptEncoding">
<match serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
</rule>
<preConditions>
<preCondition name="NeedsRestoringAcceptEncoding">
<add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />
</preCondition>
<preCondition name="IsHTML">
<add input="{HTTP_HOST}" pattern="111.22.33.444" />
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
<add input="{URL}" negate="true" pattern="wp-admin/" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
"wp-admin/" has been excluded from the IsHTML pre-condition as this was causing redirect loops in some areas of the admin.
The plugin Jetpack has been installed but this is failing to connect to Wordpress.com. Wordpress.com shows the error "There was an error retrieving your site settings." Looking at the errors in Plesk where the blog is actually hosted we see the URL below failed with a 400 bad request.
blog/?rest_route=%2Fjetpack.................
If this URL is called manually in a web browser, it gives the message "The request is not signed correctly".
Can anyone offer any advise on resolving this bad request issue please?

Related

Redirect from HTTP to HTTPS not working, 403 forbidden message in client

I am running Drupal 8.7.7 on IIS 10, with Plesk 17.8.11
From the code in web.config I would expect an automatic reroute from http://www.focusonlineperformance.nl to https://www.focusonlineperformance.nl
But instead, I get a 403 forbidden message on Chrome.
I have tried <match url=".*" />
I have tried <add input="{HTTPS}" pattern="^OFF$" />
I have the following script in web.config:
<rule name="Plesk. SSL redirect for #6" patternSyntax="ECMAScript"
stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="OFF" />
<add input="{HTTP_IS_SITEPREVIEW}" pattern="1"
negate="true" />
</conditions>
<serverVariables />
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
Thanks for any help!
Use below URL rewrite rule:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTPS force" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
make sure you configure https binding for the site and with the right certificate.
and uncheck "Require SSL" by following below steps:
Open iis manager. select your site.
Double click on SSL setting feature from the middle pane:
Uncheck the require SSL and click on apply.

Can I configure IIS to route traffic to another server?

I have a Windows server available at website.com, and I have another server with a WordPress on it.
How can I configure IIS to route website.com/blog to my WordPress?
I tried to use virtual directories, but I can only send my user to the same server.
According to your description, I suggest you could consider using ARR reverse proxy to achieve your requirement.
I suggest you could install the ARR by using this link and this link.
Then I suggest you could try to use below url rewrite rule.
<rule name="ReverseProxyInboundRule2" stopProcessing="true">
<match url="/blog/(.*)" />
<action type="Rewrite" url="http://ec2 ubuntu address/{R:1}" />
</rule>
Thank you,it worked but I had to add more code to my web.config.
My web.config:
<rewrite>
<rules>
<clear />
<rule name="Route the requests for Company1" enabled="true" patternSyntax="ECMAScript" stopProcessing="false">
<match url="(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="https://blog.raczum.com/{R:0}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<rule name="Route the subfolder blog" enabled="false" patternSyntax="Wildcard" stopProcessing="false">
<match url="https://raczum.com/blog/*" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="https://blog.raczum.com/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule> </rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" enabled="true" stopProcessing="false">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://blog.raczum.com/(.*)" />
<action type="Rewrite" value="/blog/{R:2}" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false" />
</rule>
<rule name="RewriteRelativePaths" preCondition="ResponseIsHtml1" enabled="true" stopProcessing="false">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://blog.raczum.com/(.*)$" negate="false" />
<action type="Rewrite" value="/blog/{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1" patternSyntax="Wildcard">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="*" />
</preCondition>
<preCondition name="ResponseIsHtml2">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>

ASP.NET Postback error under Reverse Proxy with IIS 8.5, URL Rewrite 2.0 and ARR 3.0

I would like to setup a reverse proxy in IIS but in my configuration I get problems with ASP.NET postbacks. When you click on any submit button of the proxied website then you get a 404 error. The URL in browser address bar is changed to the rewritten URL.
For example, the website that I need to proxy is http://website.com/host. Here http://website.com and http://website.com/host are separate web applications. Host is running as a virtual folder under website.com.
I want to access the Host from this URL: http://me.local/myhost. In IIS me.local is an asp.net web application and Myhost is added as another application as child of me.local. Everything works just fine as long as you don't click on submit button anywhere on the proxied website. Once you do this then you get to page http://me.local/host which results in 404 error. When you look at page's html source then form's action url is set correctly to /myhost
Why does the error happen? Is it possible to fix it in IIS, or do we need to make changes to the host application?
My server is running IIS 8.5. The host server is an old one with IIS 6, and web application can be asp.net 1.1 or asp.net 2.0.
The section with rewrite rules from web.config of "myhost" application is:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Route the requests for host" stopProcessing="true">
<match url="^(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://website.com/host/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<rule name="hostToDefault" stopProcessing="true">
<match url="^" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="default.aspx" appendQueryString="false" />
</rule>
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^(.*)default\.aspx$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="(.*)" appendQueryString="false" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://website.com/(.*)" />
<action type="Rewrite" value="/{R:2}" />
</rule>
<rule name="NonhostRewriteRelativePaths" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(?!host)(.*)" negate="false" />
<action type="Rewrite" value="http://website.com/{R:1}" />
</rule>
<rule name="hostRelativePaths" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/host/(.*)" negate="false" />
<action type="Rewrite" value="/myhost/{R:1}" />
</rule>
<rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img" pattern="^(.*)myhost/default\.aspx$" />
<action type="Rewrite" value="{R:1}/myhost/default" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<urlCompression doStaticCompression="false" doDynamicCompression="false" />
</system.webServer>
</configuration>

IIS Api redirect rule

I need some help with a redirect regex in my web.config. I have a website UI and an App UI which hit the same serverside API but I'm decoupling the urls that get called from either for future-proofing the app against API updates.
This is what I have so far in my web.config and it works for redirecting api.mywebsite.com to mywebsite.com, but how do I write the regex to add the version at the end so that http://api.mywebsite.com/v1/ gets redirected to http://www.mywebsite.com ?
<rules>
<rule name="Remove WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(api\.)(.*)$" />
</conditions>
<action type="Redirect" url="http://dev.blahblah.org.au{PATH_INFO}" redirectType="Permanent" />
</rule>
</rules>
<rule name="Remove WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(api\.)(.*)$" />
<add input="{PATH_INFO}" pattern="^/v(\d+)/(.*)$" />
</conditions>
<action type="Redirect" url="http://localhost{PATH_INFO}?v={C:1}" redirectType="Permanent" />
</rule>

url rewriting in iis7

I am running IIS7.5 and the URL Rewrite module.
I followed these step by step instructions to enable user friendly URL's:
Rule Templates for the URL Rewrite Module - User Friendly URL - rule template
If I enter the URL http://domain.com/default/ instead of http://domain.com/default.aspx the website throws 404: file not found error.
Here are my rewrite rules:
<rewrite>
<rules>
<rule name="RedirectUserFriendlyURL1" stopProcessing="true">
<match url="^demourl\.dev\.asenetechdev1\.com/default\.aspx$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="demourl.dev.asenetechdev1.com/default"
appendQueryString="false" />
</rule>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^demourl\.dev\.asenetechdev1\.com/default$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="false" />
</conditions>
<action type="Rewrite" url="demourl.dev.asenetechdev1.com/default.aspx" />
</rule>
</rules>
<outboundRules>
<rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Form, Img"
pattern="^(.*)demourl\.dev\.asenetechdev1\.com/default\.aspx$" />
<action type="Rewrite" value="{R:1}/ demourl.dev.asenetechdev1.com/default" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
I also tried using Intelligencia.UrlRewriter with this. But I am able to generate friendly urls on local as well as on server, but I want extensionless url, which is working ok on my local server, but not on the live server.
Your pattern is currently not matching /default/. It is only matching /default
Changing
<match url="^demourl\.dev\.asenetechdev1\.com/default$" />
to
<match url="^demourl\.dev\.asenetechdev1\.com/default/{0,1}$" />
should do it.

Resources