A server (x.com) has the following parameters:
- It is accessible from the outside from port 80.
- It has an internal service running on port 1000.
- The service needs to be accessible from a subdomain (service.x.com)
Running IIS on Windows 10, I did the following:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="URL Rewrite" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://" />
</conditions>
<action type="Rewrite" url="{C:1}://localhost:1000/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
And it worked beautifully.
The same code, on the other end, run on Windows Server 2012 R2 yields this:
HTTP Error 404.4 - Not Found
The resource you are looking for does not have a handler associated with it.
Module IIS Web Core
Notification MapRequestHandler
Handler ExtensionlessUrlHandler-Integrated-4.0
Error Code 0x8007007b
I do not understand why it works on one version of IIS and not on the other one.
I found: ARR (Application Request Routing) needs to be enable.
Of course, this is not mentioned anywhere in any of the error messages nor in log.
Related
I'm trying to deploy a Nuxt 3 app on a server using IIS.
The idea is to use reverse proxy to rewrite requests from the external https://www.example.com to the internal http://localhost:8080 where the app is running.
It should be straight forward I thought, with an inbound rule matching everything (.*) and a Rewrite URL like http://localhost:8080/{R:1}:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:8080/{R:1}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
But apparently only the dynamic routes are being served correctly, all public static files are not. On those this is the curl response: curl: (92) HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8).
Other notes:
Opening the app locally on http://localhost:8080 works perfectly.
The same behaviour occurs with a fresh Nuxt app.
Usage of iisnode seems not possible because of ES Modules incompatibility: iisnode Error [ERR_REQUIRE_ESM]: require() of ES Module (...)index.mjs not supported.
After adding a rule to force HTTPS it started working as expected, all static files are being served as expected.
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
</rule>
I want to know if anybody here can help. I have using Nest.js for my program and I have added some web socket code into my program for some new feature. However, when I deploy to the server and there are a problem to the IIS Setting.
Now I use URL rewrite for my http server. My HTTP server run on port 8200 in localhost. My web socket port is 8085. What I have tested is that I can call it in local using ws://localhost:8085/socket.io/?EIO=3&transport=websocket and also ws://192.168.X.X:8085/socket.io/?EIO=3&transport=websocket in internal network. However, I cannot call by ws://myurl.com/socket.io/?EIO=3&transport=websocket. The URL is binding with a IIS server. Below is my IIS server web.config. Is it because we socket cannot called by url? or is my web.config have something wrong? Can anybody help me?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WebSocketsReverseProxy" enabled="true" stopProcessing="true">
<match url="ws://(.*)"/>
<action type="Rewrite" url="ws://localhost:8085/{R:1}"/>
</rule>
<rule name="HttpsReverseProxy" stopProcessing="true">
<match url="(.*)"/>
<conditions>
<add input="{CACHE_URL}" pattern="^(https?)://"/>
</conditions>
<action type="Rewrite" url="http://localhost:8200/{R:1}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
remove ws:// from the first rule. iis match rule only matches folder or file but does not match the domain name. if you want to match the domain use condition server variable {HTTP_HOST}.
I have Apache NiFi running on a Windows server. I've setup HTTPS access and connected it to my AD via LDAP for users authentication. The value of property nifi.web.https.host is localhost and nifi.web.https.port is 6444 and I'm able to access the web UI through https://localhost:6444/nifi with no issues.
I want now to setup NiFi to run behind IIS on the same server so IIS acts as a proxy. I've created a new site within IIS and configured the URL Rewrite rules in its web.config file as below:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
<rule name="NiFi Reverse Proxy" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="https://localhost:6444/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Both IIS and NiFi are using the same SSL certificate from my organization.
I've configured the nifi.web.proxy.host property in the nifi.properties file to nifi01.myorg.com:443.
I'm able to access https://nifi01.myorg.com/nifi from an external computer. I see the sign in page and am able to sign in successfully. However, after the authorization is completed, I'm redirected to https://localhost:6444/nifi. If in the same browser session I type in https://nifi01.myorg.com/nifi, then I can see the main Nifi workflow UI which tells me that the sign in process did work.
Can someone help me with the redirection that is happening to https://localhost:6444/nifi. Is there something that I'm missing in the web.config or nifi.properties files?
I found this article https://community.hortonworks.com/articles/113240/running-apache-nifi-behind-a-proxy-2.html that I've not been able to follow as don't know where in IIS the settings should go.
I'm running an Azure Web App that's meant to accept XML Posts. When I post to the urls using cURL everything works, however, when using Apache Camel/HTTP the POST results in a 400 error. When I look at the log files, the only difference is cs-host field. For the cURL commands the value is just the domain (e.g. azurewebsites.net), however the Apache POST appends port 80 (e.g. azurewebsites.net:80). I added a rewrite rule that would strip the port from the call (rule details below), but the POST still results in 400 error. The closest related post I could find was here: Including Port number in HTTP HOST header causes Service Unavailable error but unfortunately it looks like it's related to Netscaler, not Azure Web App, and the resolution didn't provide any detailed guidance.. Thanks for any input!
Here's the rewrite rule:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="domain" xdt:Locator="Match(path)">
<system.webServer>
<rewrite xdt:Transform="InsertBefore(/configuration/location[(#path='domain')]/system.webServer/*[1])">
<rules>
<rule name="domainrule1" stopProcessing="true">
<match url="domain.azurewebsites.net:80(.*)" />
<action type="Redirect" url="http://domain.azurewebsites.net/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
<location path="~1domain" xdt:Locator="Match(path)">
<system.webServer>
<rewrite>
<rules>
<rule name="domainrule2" stopProcessing="true" xdt:Transform="Insert">
<match url="domain.azurewebsites.net:80(.*)" />
<action type="Redirect" url="http://domain.azurewebsites.net/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>
I want to use IIS8 to route traffic from ports 80/443 to two applications running on the same server - one sitting on port 8080 (node.js app, running as a separate service), another on port 8090 (a .NET application, running on the same IIS, handling api calls).
I have setup an app on port 80, with the following web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rewrite api to backend calls" stopProcessing="true">
<match url="^api/(.+)$"/>
<action type="Rewrite" url="http://127.0.0.1:8080/{R:1}"/>
</rule>
<rule name="rewrite everything else to frontend" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://127.0.0.1:8090/{R:1}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Unfortunately this approach doesn't work - whatever resource I try to query, I get 404 error.
In the FREB logs, requests are properly translated from OldUrl, to the NewUrl, nothing is found in cache and then the following is mentioned in logs as MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName="IIS Web Core", Notification="MAP_REQUEST_HANDLER", HttpStatus="404", HttpReason="Not Found", HttpSubStatus="4", ErrorCode="The filename, directory name, or volume label syntax is incorrect.
(0x8007007b)", ConfigExceptionInfo=""
Proxy in Application Request Routing had to be enabled as per the IIS Rewrite not working (but redirection does) topic. Issue solved :)