Nginx 负载均衡器配置
Nginx load balancer configuration
我的要求是在两个单独的节点中平衡两个 ESB Web 服务 运行 (10.110.6.29, 10.110.6.45)
我正在使用 nginx 并安装在 10.110.6.45 中。基本上,当我向 10.110.6.45 (port 80)
发送请求时,它应该对两个节点进行同样的负载平衡。
下面是 /etc/nginx/nginx.conf.
user www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream esbhnbwso2.hnb.lk{
server 10.110.6.45:8280;
server 10.110.6.29:8280;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://esbhnbwso2.hnb.lk;
proxy_http_version 1.1;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
当我尝试调用服务时 http://10.110.6.45/hnbceftapi
我得到以下 nginx 页面。
我究竟做错了什么?任何帮助将不胜感激。
<html>
<head>
<meta content="HTML Tidy for Java (vers. 27 Sep 2004), see www.w3.org" name="generator"/>
<title>404 Not Found</title>
</head>
<body bgcolor="white">
<center>
<h1>404 Not Found</h1>
</center>
<hr/>
<center>nginx/1.14.2</center>
</body>
</html>
经过一些互联网阅读,我能够使 nginx 工作。这些是我的发现,我想
分享这些。
我必须使用以下命令启用 linux 内部防火墙。
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
这些命令基本上会创建一个 public 区域并允许 http(80)、https(443) 流量。
可以通过 运行ning 下面的命令验证允许的端口。
firewall-cmd --list-ports
必须 运行 下面的命令允许 httpd - http 守护进程(Apache web 服务器 which nginx 运行s)进行 http 通信。
setsebool -P httpd_can_network_connect 1
这些配置是必需的,因为我正在处理的分发是安全增强 Linux (SELinux)。我不是系统管理员,因此我不知道这些配置。
我的要求是在两个单独的节点中平衡两个 ESB Web 服务 运行 (10.110.6.29, 10.110.6.45)
我正在使用 nginx 并安装在 10.110.6.45 中。基本上,当我向 10.110.6.45 (port 80)
发送请求时,它应该对两个节点进行同样的负载平衡。
下面是 /etc/nginx/nginx.conf.
user www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream esbhnbwso2.hnb.lk{
server 10.110.6.45:8280;
server 10.110.6.29:8280;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://esbhnbwso2.hnb.lk;
proxy_http_version 1.1;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
当我尝试调用服务时 http://10.110.6.45/hnbceftapi
我得到以下 nginx 页面。
我究竟做错了什么?任何帮助将不胜感激。
<html>
<head>
<meta content="HTML Tidy for Java (vers. 27 Sep 2004), see www.w3.org" name="generator"/>
<title>404 Not Found</title>
</head>
<body bgcolor="white">
<center>
<h1>404 Not Found</h1>
</center>
<hr/>
<center>nginx/1.14.2</center>
</body>
</html>
经过一些互联网阅读,我能够使 nginx 工作。这些是我的发现,我想 分享这些。
我必须使用以下命令启用 linux 内部防火墙。
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
这些命令基本上会创建一个 public 区域并允许 http(80)、https(443) 流量。
可以通过 运行ning 下面的命令验证允许的端口。
firewall-cmd --list-ports
必须 运行 下面的命令允许 httpd - http 守护进程(Apache web 服务器 which nginx 运行s)进行 http 通信。
setsebool -P httpd_can_network_connect 1
这些配置是必需的,因为我正在处理的分发是安全增强 Linux (SELinux)。我不是系统管理员,因此我不知道这些配置。