Based on your scenario, you don't need to set up rewrite rules on all sites — only on the ones that should forward to Server B.
But, ARR and URL Rewrite can also be configured at the server level (in applicationHost.config
), and this is where the problem usually arises.
I will provide for you some mains thing you should need to check here :
- Check if ARR/URL Rewrite is Set at the Server Level
- If you created server-wide rewrite rules (i.e., in the IIS root), they might affect all sites, even ones without explicit rules.
- Open IIS Manager → Server Node (not individual site) → URL Rewrite → see if there are any rules there.
-> Move rules to specific site level instead, unless they're meant to be global.
- 405 Method Not Allowed in ARR Usually Means:
- The proxy is trying to forward the request using a method (e.g.,
POST
) not supported by the destination. - This can happen if requests are unintentionally being forwarded to Server B for sites that shouldn't be.
-> Make sure your rules only match the intended URLs.
- Rule Matching is Too Broad
Sometimes, a rule like this bellow can unintentionally match other URLs and which captures all requests. If not properly scoped by hostname or path, it can hijack requests to other sites.
<match url="(.*)" />
-> Use conditions (<conditions>
) in your rules to check things like HTTP_HOST
or specific paths.
And about the setup, here is some things that may help you out :
For each site that should proxy to Server B:
- Open that specific site's URL Rewrite.
- Add an Inbound Rule like:
<rule name="ReverseProxyToServerB" stopProcessing="true">
<match url="^api/(.*)" />
<action type="Rewrite" url="http://serverB/api/{R:1}" />
</rule>
- Use conditions to restrict by hostname or other headers if needed:
<conditions>
<add input="{HTTP_HOST}" pattern="^api\.yourdomain\.com$" />
</conditions>
-> For other sites (your authentication server or something else), do nothing — no rules are needed if they’re not supposed to be reverse proxied.
But if you still see 405 Errors on Non-Proxied Sites:
Double-check these:
- Is ARR caching or proxying globally?
- IIS Manager → Server Node → Application Request Routing Cache → Server Proxy Settings → ensure Proxy is not applied to all requests.
- Do other sites have
web.config
with unwanted rewrite rules? - Is there a default site with catch-all rewrite rules?