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>
Related
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.
I have created a sample bot,which is working in bot emulator and azure bot service with localhost url,but when i deployed to azure and hit its live url it is giving internal error
The page cannot be displayed because an internal server error has occurred.
and web config file is
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode"/>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET,POST,PUT,DELETE,OPTIONS" />
<add name="Access-Control-Allow-Credentials" value="true" />
</handlers>
<rewrite>
<rules>
<rule name="DynamicContent">
<match url="/*" />
<action type="Rewrite" url="app.js"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
live url of site
https://hotel-reserve.azurewebsites.net/api/messages
I have a strange issue trying to run a Node app in a sub-directory on an Azure App Service.
My directory structure is:
|common
-- common_model.js
|client
-- angular 2 app js files
|server
-- server.js with other express app files
|web.config
I've configured the web.config file to point all requests to the server\server.js file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="server\server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server\server.js"/>
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
<add segment="node_modules" />
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
<iisnode watchedFiles="web.config;*.js"/>
</system.webServer>
</configuration>
When loading up the site in a browser, the content of server.js is returned and is not executed. What else might I need other than the iisnode handler configured to make this run?
Despite setting the path:
<add name="iisnode" path="server\server.js" verb="*" modules="iisnode"/>
The iisnode module seem to only function with the server.js file in the root. The solution is luckily simple enough, just create a server.js file in the root that simply includes the sub-directory file. The whole file is one line:
require("./server/server.js");
Then you can use the default iisnode handler:
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
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.
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>