I'm trying to run two node applications, one inside another in IIS to have the proper rote:
http://server/node1
http://server/node1/node2
I have this scenario in my IIS:
Default Web Site
- node1
- node2
The struggle is that the first application node (node1) works fine, but the second keep giving me Status Code 500, however when I deploy it outsite the virtual directory (node1) works, like this:
Default Web Site
- node1
- node2
This is the web.config that I'm using:
<configuration>
<appSettings>
<!-- for node1 -->
<add key="DEPLOY_PATH" value="/node1" />
<!-- for node2 -->
<add key="DEPLOY_PATH" value="/node1/node2" />
</appSettings>
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="rewrite">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
<iisnode maxNamedPipeConnectionRetry="1000" namedPipeConnectionRetryDelay="25000" />
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
I couldn't find anything on the web about it, or similar work. I want to know why the node2 application doesn't work when deployed inside node1.
Related
The problem i'm facing is that when i'm deploying my api to local test enviroment its working fine but when i deploy it to live https secured server its popping off the error "500 Internal server error"
My web config:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="api">
<match url="api/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
I have upgraded the Node.js version to 8.8.1, and updated this in the process environmental variables, iisnode.yml, Web.config and package.json.
Nonetheless, requests going to the app now get rejected with the following error:
The iisnode module is unable to start the node.exe process. Make sure
the node.exe executable is available at the location specified in the
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config>system.webServer/iisnode/#nodeProcessCommandLine
element of web.config. By default node.exe is expected in one of the
directories listed in the PATH environment variable.
I tried to update the file path in Kudu to reflect the path to the node.exe I'm interested in ("D:\Program Files (x86)\nodejs\8.1.1\node.exe"), but got an error saying I was not authorized to do this.
The relevant files:
iisnode.yml:
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.1.1\node.exe"
loggingEnabled: true
devErrorsEnabled: true
Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your Node.js application, please visit
-->
<configuration>
<appSettings>
<!--
<add key="StorageAccountName" value="" />
<add key="StorageAccountKey" value="" />
<add key="ServiceBusNamespace" value="" />
<add key="ServiceBusIssuerName" value="" />
<add key="ServiceBusIssuerSecretKey" value="" />
-->
</appSettings>
<system.webServer>
<!-- mimeMap enables IIS to serve particular file types as specified by fileExtension. -->
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<modules runAllManagedModulesForAllRequests="false" />
<!-- Web.Debug.config adds attributes to this to enable remote debugging when publishing in Debug configuration. -->
<!--<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"/>-->
<!-- Remote debugging (Azure Website with git deploy): Comment out iisnode above, and uncomment iisnode below. -->
<iisnode watchedFiles="web.config;*.js;routes\*.js;views\*.pug"
loggingEnabled="true"
devErrorsEnabled="true"
nodeProcessCommandLine="D:\Program Files (x86)\nodejs\8.8.1\node.exe --debug"/>
<!-- indicates that the server.js file is a Node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
<!-- Remote debugging (Azure Website with git deploy): Uncomment NtvsDebugProxy handler below.
Additionally copy Microsoft.NodejsTools.WebRole to 'bin' from the Remote Debug Proxy folder.-->
<add name="NtvsDebugProxy" path="ntvs-debug-proxy/blablabla" verb="*" resourceType="Unspecified"
type="Microsoft.NodejsTools.Debugger.WebSocketProxy, Microsoft.NodejsTools.WebRole"/>
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin" />
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<clear />
<!-- Remote debugging (Azure Website with git deploy): Uncomment the NtvsDebugProxy rule below. -->
<rule name="NtvsDebugProxy" enabled="true" stopProcessing="true">
<match url="^ntvs-debug-proxy/.*"/>
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<rule name="app" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="iisnode.+" negate="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="index.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- Remote debugging (Azure Website with git deploy): uncomment system.web below -->
<system.web>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
</system.web>
</configuration>
In iisnode.yml, you have nodeProcessCommandLine pointing to 8.1.1 instead of 8.8.1. Maybe that's just it?
Trying to deploy a meteorjs app to Azure, everything looks configured correctly except I'm not sure what to point to:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I do not have a server.js. I am deploying this from nitrous.io, where the app works as expected. Do I need to add a server.js file, and if so, what should be the content? Otherwise, what file is appropriate to point to?
Builded Meteor Application on output has main.js in root folder of your application, you should point your web server onto this file.
In rewrite rule use regular expression:
<match url="^(.*)$" ignoreCase="false" />
So your config file will be:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="main.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="^(.*)$" ignoreCase="false" />
<action type="Rewrite" url="main.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Also do not forget to set ENV variables for builded Meteor: MONGO_URL, ROOT_URL (domain with protocol, like: http://my.site), MAIL_URL, etc.
I'm fairly new to both Keystone and IISnode so bear with me. I've succesfully been able to run express projects with IISnode and I can run keystone.js projects with node but merging the two has been difficult. When I run the ETW traces alongside I get a "iisnode scheduled a retry of a named pipe connection to the node.exe process" multiple times before I shut it down. I've tried hooking iisnode directly to the keystone index.js file (see below from the web.config) and also to the keystone.js file at the root of the project.
<handlers>
<add name="iisnode" path="node_modules/keystone/index.js" verb="*" modules="iisnode" />
</handlers>
My hunch is that I need to hook it up to the keystone.js file as you normally do to start up the project but you typically need to add a 'keystone' parameter alongside which I'm not quite sure how I can do this with iisnode. Can anyone help me out?
The web.config handler path should be set to your application's entry point, and not node_modules\keystone\index.js. If you used the keystone Yoeman generator, the entry point is the keystone.js file in the root folder of your app.
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="keystone.js" verb="*" modules="iisnode" />
</handlers>
...
</system.webServer>
</configuration>
I have more detail instruction of how to setup keystone.js at IIS.
http://www.dakehe.info/blog/post/deploy-keystonejs-node-cms-at-iis
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="keystone.js" verb="*" modules="iisnode" />
</handlers>
<defaultDocument enabled="true">
<files>
<add value="keystone.js" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Catch All">
<match url="/*" />
<conditions>
<add input="{PATH_INFO}" pattern=".+\.js\/debug\/?" negate="true" />
</conditions>
<action type="Rewrite" url="keystone.js" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
<iisnode node_env="production" loggingEnabled="true" debuggingEnabled="true" devErrorsEnabled="true" />
</system.webServer>
</configuration>
How do we tell iisnode to run our Node.js application environment in production/development/test?
We have successfully gotten our Node.js app running with iisnode but process.env.NODE_ENV is coming out as 'undefined'.
At the moment, our web.config file is written this way:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="app">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
<appSettings>
<add key="NODE_ENV" value="production" />
</appSettings>
</configuration>
Joachim is right above that adding <iisnode node_env="production" /> to web.config allows control over the NODE_ENV value. Another way is to add the iisnode.yml file next to your web.config, and in there spcify the NODE_ENV value as node_env: production. See other settings you can use in iisnode.yml at https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml
For the sake of clarity the web.config file would look like this:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="app">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
</hiddenSegments>
</requestFiltering>
</security>
<iisnode NODE_ENV="production" /> <=== Add env required here
</system.webServer>
</configuration>