Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
126
rated 0 times [  129] [ 3]  / answers: 1 / hits: 18305  / 9 Years ago, tue, september 8, 2015, 12:00:00

I want to install Nginx on Windows, and to run two node application. How can I do this?



I've tried to download Nginx 1.6.3, but I don't find something relevant about how to run on Windows. Just for Linux. I think there should be some modules for node.



Any advice will be useful!


More From » node.js

 Answers
23

I never run Nginx on Windows, but the official documentation says how: http://nginx.org/en/docs/windows.html.



To run two node applications with Nginx, it's necessary to create a proxy. This is an example of how to alter the nginx.conf file for this:



worker_processes 1;

events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
access_log C:varlognginxaccess.log;
location ~ ^/(javascripts|stylesheets|images) {
root C:app1public;
expires max;
}
location / {
proxy_pass http://localhost:3000;
}
}
server {
listen 81;
server_name localhost;
access_log C:varlognginxaccess.log;
location ~ ^/(javascripts|stylesheets|images) {
root C:app2public;
expires max;
}
location / {
proxy_pass http://localhost:3001;
}
}
}


In this case, there are two node applications, one running on port 3000 and an other on port 3001 - the Nginx works as a proxy.



Further documentation: https://www.nginx.com/blog/nginx-nodejs-websockets-socketio/.



In your case, the configuration file are localised in: C:nginx_v1_6confnginx.conf



Backup the default file and update the content with what I posted.



Finally, you can test the reverse-proxy through localhost (port 80 default) and localhost:81, if the nodes servers and Nginx server are running.


[#65142] Sunday, September 6, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
peytont

Total Points: 215
Total Questions: 110
Total Answers: 111

Location: Armenia
Member since Sat, Dec 31, 2022
1 Year ago
;