简体   繁体   中英

Nginx - Load balancing returns 404 on Windows

I have installed Nginx for Windows (64-bit) from here because the official binaries are 32-bit. The aim is to use Nginx for load balancing NodeJS applications. I am following instructions from here where, the link to sample basic configuration file also exists.

The following configuration file works successfully on Linux where nginx was installed via Ubuntu PPA. The servers are themselves started via pm2 .

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

upstream top_servers {
    # Use IP Hash for session persistence
    ip_hash;

    # Least connected algorithm
    least_conn;

    # List of Node.JS Application Servers
    server 127.0.0.1:3001;      
    server 127.0.0.1:3002;     
    server 127.0.0.1:3003;      
    server 127.0.0.1:3004;      
}

server {
    listen 80;

    server_name ip.address;

    location /topserver/ {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://top_servers;
        proxy_set_header   X-Request-Id $request_id;
    } 
}

However, this file does not work with Windows. I am getting an error as 'No such file or directory' under the html folder of Nginx installation on Windows. I haven't done any such setting for Linux.

Can you please help me convert the above configuration file for Windows?

NOTE I don't have a choice - Windows is a must for this project.

So, I over-wrote the contents of conf/nginx.conf with the contents shown above. First, I got an error as "map" directive is not allowed here . Then, after removing this directive, I got another error as "upstream" directive is not allowed here" . I think, the binaries I am using does not support load balancing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM