I'm wondering if anyone could help with getting a sails JavaScript app running in IIS 7 on Windows.
https://github.com/tjanczuk/iisnode/issues/298 did not prove to be helpful for me.
I have gone through the iisnode setup and created this as my web.config file:
<configuration>
<system.webServer>
<!-- Tell IIS to use the iisnode module to run your
application -->
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<!-- Add iisnode with the #nodeProcessCommand line if
you see the error: Make sure the node.exe executable
is available at the location specified in the
system.webServer/iisnode/#nodeProcessCommandLine element
of web.config. -->
<iisnode
nodeProcessCommandLine="%ProgramFiles%\nodejs\node.exe"
/>
<!-- Since behind the covers, Sails.js is just an express app
rewrite all urls to processed by iisnode via app.js. This
will sort out things like the routing to your public
resources (images, js, styles) and all configured rest
endpoints. -->
<rewrite>
<rules>
<rule name="root">
<match url=".*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Sails is installed and when I run the server from the terminal sails lift I can access the app at http://localhost:1337/, but when I attempt to access it through the IIS port8090 I receive a HTTP 500 with the message:
To run an app using node app.js, you usually need to have a version of sails installed in the same directory as your app.
To do that, run npm install sails
Alternatively, if you have sails installed globally (i.e. you did npm install -g sails), you can use sails lift.
When you run sails lift, your app will still use a local ./node_modules/sails dependency if it exists,
but if it doesn't, the app will run with the global sails instead!
Related
I use IIS in Windows to run several web page servers.
And this time, I studied Nuxt.js.
Build a project created with Nuxt.js using the "npm run build" command.
I know that if you go into that folder and "npm run dev", the server opens on port 3000.
At this time, instead of "http://example.com:3000" on the web browser, I would like to launch the service through "http://example.com".
How shall I do it?
Is there a way to set it up in IIS Manager?
If not, should we consider a new web server instead of IIS?
If not, is there a way to set it up in Nuxt.js?
I tried the HTTP redirection feature in IIS Manager, but I could not get the desired result.
If you want to access the website on port 3000 by entering "http://example.com" in the browser address bar, you can do it through IIS reverse proxy.
First of all, you need to install URL Rewrite module and ARR module on IIS.
Then you need to double-click the Application Request Routing Cache on the server level, and select "Server Proxy Settings" on the right tree node, check "Enable Proxy" and apply.
According to your description, you need to have two websites on your IIS, one is the default website (port 80), and the other is the application website you deployed to IIS (port 3000). Next you need to create a rewrite rule on the default website, as follows:
<rewrite>
<rules>
<rule name="test" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://example.com:3000/{R:1}" />
</rule>
</rules>
</rewrite>
By the above method, you can access your application through the URL: "http://example.com".
With HttpPlatformHandler you can easily host Nuxt.js web apps on IIS, but changes to your project are required as below,
Nuxt 2.x
The official guide to host Nuxt 2.x for Azure App Service (Windows) shows the general hints,
Create server\index.js.
Modify nuxt.config.js.
but it misses important steps,
You must add express and nuxt-start as dependencies (check your package.json).
Change const nuxt = await loadNuxt(isDev ? 'dev' : 'start') to simply const nuxt = await loadNuxt('start'), as isDev isn’t defined anywhere.
Then your web.config should look similar to,
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\node.log" startupTimeLimit="20" processPath="C:\Users\<user name>\AppData\Roaming\nvm\v16.13.2\node.exe" arguments=".\server\index.js">
<environmentVariables>
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
<environmentVariable name="NODE_ENV" value="Production" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Note that iisnode mentioned in that Nuxt.js guide is no longer maintained, and only HttpPlatformHandler is recommended.
Note that rewrite rules in official guide were not added as the minimal sample project does not require them, but you can add them for your project if needed.
Nuxt 3.0
The steps are simplified,
npx nuxi init test-nuxt
cd test-nuxt
npm install
npm run build
with web.config,
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\node.log" startupTimeLimit="20" processPath="C:\Users\<user name>\AppData\Roaming\nvm\v16.13.2\node.exe" arguments=".output\server\index.mjs">
<environmentVariables>
<environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
<environmentVariable name="NODE_ENV" value="Production" />
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
Reference
My blog post on Nuxt 2.x
My blog post on Nuxt 3.0
Nuxt.js for Azure guide
I developed an App on REMIX framework. But ı do not know how will i publish it on IIS server on Windows Server 2022.
Which opitons should selected for IIS.
npx create-remix#latest
? Where would you like to create your app? (./my-remix-app)
? Where do you want to deploy? Choose Remix if you're unsure, it's easy to change deployment targets. (Use arrow keys)
❯ Remix App Server
? TypeScript or JavaScript? (Use arrow keys)
❯ TypeScript
Remix requires Node.js when running on Windows. You should select Remix App Server.
There are plenty of articles online on how to set up a reverse proxy on IIS. You want to proxy to RAS running on localhost:3000 (by default).
https://www.google.com/search?q=iis+nodejs+reverse+proxy
The best way for the React Remix framework is to select Remix App Server, then run remix build to build the app for production, and run npm start to run the server. After performing the above operations, please treat it as a normal Node.js server, and follow the Conventional Way - deploying a node.js application on windows IIS using a reverse proxy.
Install Node.js on Windows Server
Deploy and test Node.js applications
Create a website for our Node.js application on IIS
Configure Reverse Proxy on IIS
Thanks for answers which showed me a way for found a solition.
Install Node.js on Windows Server .
Install IIS Node on Windows Server.
Install URL Rewrite on Windows Server.
Upload all files to under your web site folder on wwwroot except .cache,build,public/build,node_modules folders.(we will install them on server.)
Under web site folder, type command on cmd npm install
Type command npm run dev
Create a web.config file main path of web site. Codes are :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<iisnode loggingEnabled="false" nodeProcessCommandLine="C:\Program Files\nodejs\node.exe" />
<handlers>
<add name="iisnode" path="/build/index.js" verb="*" modules="iisnode" />
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
<add segment="iisnode" />
</hiddenSegments>
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I have created Node.js application on Visual studio 2019, and I want to deploy it on IIS.
How I can deploy node.js application and Node.js express applications on IIS on local system
I have tried many solutions but none of them completely helpful
The link below some how helpful but confusing and lot of content to read
https://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx
Here some simple solution for above problem
Node.js deplyment on iss
Install IISNODE
open cmd as admin
cd "C:\Program Files\iisnode" (or "C:\Program Files (x86)\iisnode" if you installed the 32bit version
Type setupsamples.bat
Install MS URL rewrite using web installer
add web.config with code
<configuration>
<system.webServer>
<!-- indicates that the server.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="sendToNode">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
publish node.js project
paste published site on inetpub-->wwwroot
run cmd as admin
run command on website folder
For node
npm install
For Node Express
npm install express
Create IIS website
start browsing
We are currently having some troubling in deploying a Node.js application on a Windows WebApp and we suspect that the problem is in the web.config file.
Here is Project Directory Structure:
We are using the default web.config with a few changes:
The application file is app.js and the public folder is dist/
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
<!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="app.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- 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="dist{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>
<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<!--
You can control how Node is hosted within IIS using the following options:
* watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
* node_env: will be propagated to node as NODE_ENV environment variable
* debuggingEnabled - controls whether the built-in debugger is enabled
See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->
</system.webServer>
</configuration>
Currently, the IIS Rewrite module is adding dist/ to the URL, like so: http://xxxxxxx.azurewebsites.net/dist/
And we have an iisnode error message:
HRESULT: 0x2
HTTP status: 500
HTTP subStatus: 1001
HTTP reason: Internal Server Error
I tried checking the Failed Request Tracing logs but no failed request was logged.
Could someone tell me what is happening in my case ?
EDIT:
I decided to start back from scratch and created a new Web app.
I built the node.js app with the kudu console and (using the same web.config) the server now fetches correctly the index.html file in dist/.
So far so good, and we correctly land on the login page.
The problem now is that iisnode fails to process the POST request with the user credentials.
As Julien suggested, I tried changing the virtual directory of the app and had different errors:
1st case:
Virtual directory: /
Path: site\wwwroot
Error: The same iisnode error as the above
2nd case:
Virtual directory: /
Path: site\wwwroot\dist
Error: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Any thoughts on that ?
Thank you
Actually, your web.config is correct.
You can try replacing the content of app.js with the following minimal Node.js app to see if it works.
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello Azure');
});
server.listen(process.env.PORT);
Important: use process.env.PORT as the port in your script when it runs on Azure Web Service.
Depending on how you are pushing your App to web app, you can try to:
Use the PROJECT environment variable to specify that your app is in the dist folder, as explained here.
Define a virtual directory in the web app settings to specify that the root folder of your application is site\wwwroot\dist. You can find a JSON example of configuration here or use the Application Settings blade in the Azure portal.
Hope this helps
Julien
I started learning server side coding a month ago, I build a nodejs project and webservices with get and post requests using 'express' framework and mssql.
My project file includes a 'main.js' file and a 'node_modules' folder.
I'm trying to host this project on IIS but have no idea or experience on how to do so.
Will i have to package my project in some way.
Can i host nodejs projects on IIS? If so, then what are the steps that I need to do so.
I have a windows server running IIS with mysql installed there.
Here is a step by step...
if you havent done so install node, iisnode and urlrewrite
add a website to iis
edit the hosts file
add your website url to host
check your new website modules to ensure iisnode is installed
If its there you're good
create the node app code JS file
Put this code in the file
var express = require("express");
var app = express();
app.get("/", function(req, res) {
res.send("Hello Worlxxxxd!");
});
// This is REQUIRED for IISNODE to work
app.listen(process.env.PORT, () => {
console.log("listening");
});
add a web.config file to the directory and put this code in it
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="node_app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="nodejs">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/node_app.js" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="node_modules" />
<add segment="iisnode" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
</configuration>
in a browser navigate to the new site and you should get this error because you haven't installed express package
open a command prompt and install express
refresh the web page and voila
I'm a little late to the party, so you've probably either solved this problem or gone a different route.
You can run node applications inside of IIS using iisnode.
I, personally, have had mixed success getting iisnode running, but it is definitely possible.
I'd recommend using the URL Rewriting (https://www.iis.net/downloads/microsoft/url-rewrite) and Application Request Routing (https://www.iis.net/downloads/microsoft/application-request-routing) IIS modules. Install these on your server hosting IIS.
In IIS create an application that points to the directory where your node application is running (although this path is not actually used!):
In this new application, create a Rewrite Rule using the Reverse Proxy template, and point to your locally served node js application:
And now, you can browse to your IIS hosted site, using the IIS application you had configured, and it will show your node.js hosted site:
One of the main benefits of this approach is that the SSL cert issued to IIS can be used with an "http" hosted node.js application.
I've got node.js running from the command line, but this could be done as a service if needed.