HTTPS和iisnode

我通过使用iisnode与IIS结合使用节点。

在我看来,我以前在Node中configuration服务器的工作现在可以直接在IIS中完成。

像:

  • httpsconfiguration(和证书)
  • http到httpsredirect

这是否意味着我可以摆脱这样做的节点代码,只是为了IIS方法?

var fs = require('fs'); var https = require('https'); var options = { key: fs.readFileSync('./ssl/xxxxxxx.private.pem'), cert: fs.readFileSync('./ssl/xxxxxxx.public.pem'), }; https.createServer(options, app).listen(443); 

是。 你应该在IIS和Windows上执行所有的sslconfiguration。

这是我用在生产上的东西。

在应用程序上,只需写入

 var app = express(); app.listen(process.env.port); 

然后用于iisnode的web.config

 <configuration> <system.webServer> <handlers> <add name="iisnode" path="app.js" verb="*" modules="iisnode" /> </handlers> <rewrite> <rules> <rule name="HTTP to Prod HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </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> <!-- Don't 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 application entry point --> <rule name="DynamicContent"> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True" /> </conditions> <action type="Rewrite" url="app.js" /> </rule> </rules> </rewrite> </system.webServer> </configuration>