IIS URL Rewrite with Wrangler/workers

28 Views Asked by At

we are trying to set up wrangler on our local dev and feature environments.

we have 2 brands/sites that run out of a single IIS Site. We have configured a URL Rewrite rule that checks for the HTTP Host to match and then rewrites to

https://localhost:8090{R:1} or http://localhost:8091/{R:1}``

in Wrangler we are listening on ports 8090 and 8091 in 2 separate terminals, and each is configured to send to the appropriate route. It seems that the main request is not actually making it to the workers console, just the css and js. However when i switch the rule to a redirect, i see all requests including main request in the wrangler console. this is not a workable solution though because localhost isnt accessible from outside the server.

this is sort of an first part of the problem. we are also having all kinds of issues with HTTPS between IIS and wrangler, but id like to try and solve this problem first. Below are my rewrite rules and the wrangler config:

`

<rules>
    <clear />
    <rule name="ACMEWorkers" enabled="true" stopProcessing="false">
        <match url="(.*)" />
        <action type="Rewrite" url="http://localhost:8090/{R:1}" appendQueryString="true" logRewrittenUrl="true" />
        <conditions trackAllCaptures="true">
            <add input="{HTTP_HOST}" pattern="^dev7000.ACME\.com$" />
            <add input="{HTTP_has_workers}" pattern="FALSE" />
            <add input="{HTTPS}" pattern="ON" />
        </conditions>
    </rule>
    <rule name="CORPWorkers" enabled="true" stopProcessing="true">
        <match url="^(.*)$" />
        <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
            <add input="{HTTP_HOST}" pattern="^dev7000.CORP\.com$" />
            <add input="{HTTP_has_workers}" pattern="false" />
            <add input="{HTTPS}" pattern="ON" />
        </conditions>
        <action type="Rewrite" url="http://localhost:8091/{R:1}" logRewrittenUrl="true" />
    </rule>

`

[env.ACME-local]
name = "ACME-local"
port = 8090
vars = { ENVIRONMENT = "staging" }
main = "src/index.js"
compatibility_date = "2023-04-04"
route = { pattern = "dev7000.ACME.com/*", custom_domain = true, zone_id = "ACME.com" }

[env.CORP-local]
name = "CORP-local"
port = 8091
vars = { ENVIRONMENT = "staging" }
main = "src/index.js"
compatibility_date = "2023-04-04"
route = { pattern = "dev7000.CORP.com/*", custom_domain = true, zone_id = "CORP.com" }

tried adjusting the rules using all different conditions. also switching to a redirect instead of a rewrite seems to get all requests at least to hit workers.

0

There are 0 best solutions below