Skip to main content

Running Node.js alongside IIS on Windows


Most of the time when you are looking for a way to run Node.js as a production server on Windows you will just run into IISNode , now IISNode is a great thing ,but I'm a fan of choice and most importantly , not a fan of XML web config files.

I wanted to run my node server on what ever port I wished,or maybe even a different server and just have IIS reroute the traffic from a particular URL to the node process(so a proxy), this allows you to still manage your own load balancing and possibly scale up from that point without having to bother with IIS again.

So first things first you will want to download and install the URL Rewrite and ARR modules for IIS

Once thats done lets crack open IIS and open up Application Request Routing, then navigate to Server Proxy Settings and Check Enable Proxy and Apply.








Now lets create an an application on our Default Website that will link our url to the node process, here im directing it to an empty directory wich will eventually contain the web.config file (don't worry , you wont have to write it out).


Now select the application and click on the URL Rewrite IIS module, Once here click Add Rules on the right hand pane and select Reverse Proxy



After that its simple , just enter the url of the node process, which in this case is 127.0.0.1 on port 8080. a config will be placed in the blank directory and your traffic should be rerouted to your node process.



NOTE: Sometimes one needs to move the server to a new application pool due to permission problems. 

Im running a hello world node http server on port 8080 so lets see the result when we browse to localhost/nodeserver :


Success!!!

Running node as a service

Now that we have IIS rerouting traffic to our node process we need to think about running that node server as a service , we cant just leave an open terminal on our server , its bound to get closed , for this we use Winser which you can read all about here, its a simple way to run your node server as a windows service so that it will never let you down.


Issues: The only issue I've run into and that you may run into as well is based on the permissions of the empty folder ,this causes your browser to hang when browsing to the url. I played around a while with folder permission and eventually switching nodeserver to a different application pool worked , unfortunately I cannot pinpoint if it was moving pools or a combination of that and permission modification that solved the problem.


Comments

Popular posts from this blog

Setting up Qt Creator for assembly

After fiddling with inline asssembly (not very successfully) ,I recently decided to try writing proper assembly and compiling with NASM in Linux. After writing a hello world using gedit and having a terminal open for compiling,linking and running I had a thought.,there has to be a better way to do this. So I tried Qt Creator ,because I know it's easy to add custom build and run commands,and what do you know? I got it to work. Here's how,my screenshots and assembly code are in Linux but the set up should be the same regardless of the operating system,if you are not using Linux then just use the same commands you use to assemble in your operating system. First off ,create a new console application: I named mine ASM Rename the main.cpp to main.asm and delete all the text inside.then insert some assembly: Now open up the “Project” tab and edit the build settings,remove the current build and clean steps and remove the “-build-desktop” from the en...

Using delegates in Objective-C

Why use delegation? Well when writing Objective-C programs in Xcode we are encouraged to use the MVC(Model View Controller) structure.In MVC a model cannot send messages directly to a specific controller.This can become a problem if data in your model changes independantly and you need to update this information in your view via the controller(The model must never communicate directly with the view).This is where a delegate comes in,it allows messages to be sent from the model to a controller that is not specified in the model but is rather specified by the controller,in other words the controller specifies itself. If you dont really understand what im talking about so far ,don't worry.I didn't understand delegates either until I needed one,but hopefully by the end of this tutorial you will understand not only how to use a delegate ,but the reason you would want to use one. Program breakdown For this tutorial we will write a program that has a model that will change an...

Fix ssh -Y with other Macs OSX 10.8 Mountain Lion

You may have realised that when you try use ssh -Y on another Mac from Mountain Lion you get the following error : Warning: No xauth data; using fake authentication data for X11 forwarding.X11 forwarding request failed on channel 0 Fixing this error only takes some simple configuration. All you have to do is add these lines to the following files on both machines: /etc/sshd_config X11Forwarding yes XauthLocation /opt/X11/bin/xauth XauthLocation /usr/X11R6/bin/xauth /etc/ssh_config XauthLocation /opt/X11/bin/xauth XauthLocation /usr/X11R6/bin/xauth That should be all you need to get rid of the authentication error. Hope this was helpful.