How to deploy react Remix framework to IIS on windows server 2022? - iis

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>

Related

How to build Node js app in production for hosting in IIS

I have a node js server that I want to deploy on IIS. Since I am new to node, I am unable to understand the following:
How to bring the code in production mode?
How to build the code in production mode?
How to deploy it to IIS
Thank you
You can follow the below steps to deploy the node js app in iis:
1)Install iisnode
https://github.com/Azure/iisnode
2)Download and install url rewrite extension
3)set the port number in your node app by using below code:
process.env.PORT
note: use the same port number in iis site bindings
4)add the site in iis and give your node js app folder path and set the site bindings
5)Add below code in web.config file:
<configuration>
<system. Webserver>
<handlers>
<add name=""iisnode"" path=""server.js"" verb=""*"" modules=""iisnode"" />
</handlers>
<rewrite>
<rules>
<rule name=""rule1"">
<match url=""/*"" />
<action type=""Rewrite"" url=""server.js"" />
</rule>
</rules>
</rewrite>
</system. Webserver>
</configuration>
Note: please give the iis_iusrs and iusr full control permission to the site root folder

How to deploy node.js application and node.js express applicaion on IIS

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

How to deploy a create-react-app using Azure DevOps?

I've spent the past 2 days trying to figure out how to deploy my web app using Azure DevOps but nothing shows up. I used FileZila to see if the files generated by the build is uploading and all the files are there under the wwwroot folder. I tried manually uploading the files using FileZilla too. At this point I'm getting really frustrated because I've tried everything I found online to deploy the app. DevOps works perfectly fine, the part that isn't working is my web app actually showing up when I go to the URL.
I followed all the tutorials I could find.
No idea why this is asking me to deploy my code when the code is clearly deployed :/
Failed to reproduce your issue,you could follow my working steps as below:
1.Import repository,I used the git url from this document:https://github.com/MicrosoftDocs/pipelines-javascript
2.Create Build Pipeline.
3.Run the Build process.
4.Release the project and choose Nodejs Web APP.
5.Choosing the azure web app service in your subscription.
6.Navigate to your project url.
7.My files in the /wwwroot directory.
And web.config file as below:
<?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="server.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="^server.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="server.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>
You could check any differences between your steps and mine.Any concern,please let me know.
The reason I was having this issue was that I was trying to deploy to a Linux web app in Azure.
Unfortunately, I couldn't find a way around getting the deployment to Linux working, but as soon as I switched the app to windows based app service plan the app worked instantly.
If you're deploying react app to azure app service linux instance via Azure devops, then be sure to add following 'Startup command' to the azure app service deployment task:
pm2 serve /home/site/wwwroot --no-daemon --spa
Azure App Service Linux uses Nginx for web server, and has pm2
installed. Know more about pm2 here ->
https://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/
To automatically redirect all queries to the index.html use the --spa
option.
After devops run, your azure app service Configuration -> General Settings, will look like:

host node js on windows server (iis)

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.

Sails.js iisnode configuration

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!

Resources