[英]Nginx - Load balancing returns 404 on Windows
I have installed Nginx for Windows (64-bit) from here because the official binaries are 32-bit. 我从这里安装了Windows版Nginx(64位),因为官方二进制文件是32位。 The aim is to use Nginx for load balancing NodeJS applications.
目的是使用Nginx来平衡NodeJS应用程序的负载。 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. 以下配置文件在通过Ubuntu PPA安装了
nginx
Linux上成功运行。 The servers are themselves started via pm2
. 服务器本身通过
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. 但是,此文件不适用于Windows。 I am getting an error as 'No such file or directory' under the
html
folder of Nginx installation on Windows. 我在Windows上Nginx安装的
html
文件夹下收到“没有这样的文件或目录”错误。 I haven't done any such setting for Linux. 对于Linux,我尚未进行任何此类设置。
Can you please help me convert the above configuration file for Windows? 您能帮我将上述配置文件转换为Windows吗?
NOTE I don't have a choice - Windows is a must for this project. 注意:我别无选择-Windows是该项目的必备条件。
So, I over-wrote the contents of conf/nginx.conf
with the contents shown above. 因此,我用上面显示的内容
conf/nginx.conf
了conf/nginx.conf
的内容。 First, I got an error as "map" directive is not allowed here
. 首先,出现错误,因为
"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. 然后,删除此指令后,出现另一个错误,因为
"upstream" directive is not allowed here"
。”我认为,我使用的二进制文件不支持负载平衡。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.