Last active
June 7, 2019 22:51
-
-
Save BananaAcid/caead73db3c15bc20435f1e25e2bafac to your computer and use it in GitHub Desktop.
iisnode handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 1. install: https://github.com/Azure/iisnode/releases 2. add website in IIS, 3. drop this file into a node website --> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.webServer> | |
<handlers> | |
<add name="iisnode" path="app.js" verb="*" modules="iisnode" /> | |
</handlers> | |
<iisnode | |
devErrorsEnabled="true" | |
maxRequestBufferSize="1073741824" | |
/> | |
<!-- stop it from catching HTTP headers, resulting in HTTP-verb error --> | |
<modules> | |
<remove name="WebDAVModule" /> | |
</modules> | |
<!-- allow files of 1GB to be transfered --> | |
<security> | |
<requestFiltering> | |
<requestLimits maxAllowedContentLength="1073741824" /> | |
</requestFiltering> | |
</security> | |
<rewrite> | |
<rules> | |
<!-- SSL Certificate validation --> | |
<rule name="Let's Encrypt http-01 challenge" patternSyntax="ECMAScript" stopProcessing="true"> | |
<match url="^.well-known\/.*?" /> | |
</rule> | |
<!-- Rewrite all http requests to https --> | |
<rule name="Redirect HTTP to HTTPS" stopProcessing="true"> | |
<match url="(.*)" /> | |
<conditions> | |
<add input="{HTTPS}" pattern="^OFF$" /> | |
</conditions> | |
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> | |
</rule> | |
<!-- Rewrite all www requests to .domain --> | |
<rule name="Redirect www.domain.com to domain.com" patternSyntax="ECMAScript" stopProcessing="true"> | |
<match url=".*" /> | |
<conditions> | |
<add input="{HTTP_HOST}" pattern="^www.domain.com$" /> | |
</conditions> | |
<action type="Redirect" url="https://domain.com/{R:0}" /> | |
</rule> | |
<!-- Don't interfere with requests for logs --> | |
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true"> | |
<match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$" /> | |
</rule> | |
<!-- Do not interfere with requests for node-inspector debugging --> | |
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true"> | |
<match url="^app.js\/debug[\/]?" /> | |
</rule> | |
<!-- First we consider whether the incoming URL matches a physical file in the /public folder --> | |
<rule name="StaticContent"> | |
<action type="Rewrite" url="public{REQUEST_URI}" /> | |
</rule> | |
<!-- All other URLs are mapped to the node.js site entry point --> | |
<rule name="DynamicContent"> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" /> | |
</conditions> | |
<action type="Rewrite" url="app.js" /> | |
</rule> | |
</rules> | |
</rewrite> | |
<!-- you should use a caching solution, but this will prevent updates when there was a code change --> | |
<caching enabled="false" enableKernelCache="false" /> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment