Can i run IIS and Node.JS simultaneously? - node.js

Actually i have a server where there is hosted a website written in ASPX so it use IIS to run.
Now i would add an API that will permise to add some data to server database, the API is written in Node.JS so i was wondering if it's possible to run simultaneously Node and IIS.
Node is listening on port 3000 and obviously if i simply try to run 'websitedomain.it:3000/data' it doesn't work..
If something like this is possible how could i implement it?

Of course, you could run IIS and Node.JS simultaneously.
When you host webform website in IIS, it will not prevent node.js application being accessed.
You could self-host your node.js application then use URL rewrite rule and ARR to rewrite websitedomain.it:3000/data to your node.js api.
https://dev.to/petereysermans/hosting-a-node-js-application-on-windows-with-iis-as-reverse-proxy-397b
Of course, you could host your nodejs application in IIS with iisnode extension directly.
https://github.com/tjanczuk/iisnode/releases

Related

Node.js web gui access external node.js web server

I have a node.js web gui and server running on a localhost port and another node.js web server running on another localhost port. I haven't been successful locating an example of access the 2nd web server from the 1st. I want to post a "GET" to the 2nd server and have it respond with the piece of data using XMLHttpRequest. Does someone have an example of something similar? Or is this even feasible?

How to use Nginx to load pages through express router

So I'm building an end to end application (With node.js/mysql back end, react front end, and using the express router), but I'm having trouble setting up a local development server. I don't need it to be accessed from the outside world, just be able to load different pages connecting to the express router. I don't have any dev ops experience for this, so I'm trying to use nginx to point it to the router which I can't figure out. Is there an easier way to do this?
I also need to run this on a windows machine, which just makes everything slightly more complicated
It's not entirely clear from your description how your application is set up and what the role of Nginx is.
So I'll start from the beginning...
Nginx is primarily an HTTP server which can also function as a proxy for HTTP requests. If you've written a Node.js application using Express, you have written an HTTP server which can handle any routes you have set up and can also serve your static assets (ie. HTML pages, images, front-end Javascript, CSS, etc.). In this case, there is no need for Nginx - if you wrote something like the Express "Hello World" app, then you will see a message like "Example app listening on port 3000" and you can connect to your app by visiting http://localhost:3000 in your browser.
That's it - there's literally nothing else to your app and there is no need for Nginx (or any other HTTP server) to run your application.
Now that's not to say that there is no role for Nginx in your application, but it may not be as an HTTP server. One possibility is that you may want to set up Nginx as a proxy, to handle certain routes by sending the requests to your Node application. For example, I set up an application some time ago which uses Nginx to proxy API routes for my application to a Node application and to serve static assets directly. This may be what you have in mind - if it is, you will need to configure different routes in Nginx to serve different things (and unfortunately there's not enough information in your question to give suggestions on this).
As an aside, you're probably going to find this much easier to set up using Linux - perhaps the Windows Linux Subsystem, a virtual machine running Linux, or Docker.
You'll probably want to use
https://github.com/facebook/create-react-app
create-react-app my-app will set up everything you need (webpack, etc.), and then
npm start will start a local development server.
Should work on Windows, but I don't know, because I wouldn't use/recommend Windows ;-)

Can NodeJs - http module be hosted to process ASP/.NET web site pages?

I want to host website locally which would be accessed with a embedded Browser Control on a Desktop application.
I am trying to find a solution by hosting a http listener with the capability to process the ASP.NET/CSHTML(Razor) server pages.
NodeJS is an option to host a http listner, but how to register/associate the ASP Http Handler to NodeJs-HttpModule for processing these server pages.
Is this possible?
Thank you very much for your interest in my query. Please help.

Running two applications on Linux server and routing

I have got 2 applications:
Nodejs application and Angular application.
I would like to host them both on the same Linux server (Linode).
Also I have a DNS record for example : forexample.com.
I would like that when I navigate to api.forexample.com it will navigate inside the linux server to the Angular application, and I should see the angular pages.
The nodejs application is a API application which I would like other people to make all the HTTP requests to api.forexample.com/api.
So the question is how to make the navigation inside the linux server?
Generally speaking to run multiple applications on a server. First you need to add an A record on your DNS record for api.forexample.com
Then you can use nginx to handle the two applications. The way it will work is that each application will run locally on its own port and nginx will handle the url you provide and map it to the appropriate application. Check out this tutorial: Configure Nginx as a web server
In your situation you could serve the angular app from the node application.
Check this too: How to serve an angular2 app in a node.js server

Openshift with nodejs and nginx

context
I've a running app on Openshift using a nodejs (nodejs-0.10). I would like to add a ngix as first proxy to serve static files only.
problem
The question is how to add nginx to a running app on Openshift. I saw this cartridge gsterjov/openshift-nginx-cartridge but the README instructs how to create a new app using the nginx, but not how to add it to an existing app.
You can not add a secondary web framework cartridge to an application. Each application can only have one web framework cartridge installed at a time. You might need to setup a second application and setup nginx as a proxy if you want the requests to hit that first and serve static assets, then proxy the dynamic requests back to your node.js application.

Resources