nginx 역방향 에이전트 부하 균형 기능
3 web , web
web01 10.0.0.7 172.16.1.7
web02 10.0.0.8 172.16.1.8
web03 10.0.0.9 172.16.1.9
1
lb01 10.0.0.5 172.16.1.5
①. 웹 서버 배치
: nginx : web nginx
mkdir /server/tools -p
cd /server/tools
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar xf nginx-1.12.2.tar.gz
yum install -y pcre-devel openssl-devel
useradd -M -s /sbin/nologin www
cd nginx-1.12.2
./configure --prefix=/application/nginx-1.12.2 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
make && make install
ln -s /application/nginx-1.12.2 /application/nginx
/application/nginx/sbin/nginx
netstat -lntup|grep nginx
: nginx
server {
listen 80;
server_name www.etiantian.org;
root html/www;
index index.html index.htm;
}
server {
listen 80;
server_name bbs.etiantian.org;
root html/bbs;
index index.html index.htm;
}
scp -rp /application/nginx/conf/nginx.conf 172.16.1.8:/application/nginx/conf/
scp -rp /application/nginx/conf/nginx.conf 172.16.1.9:/application/nginx/conf/
:
mkdir /application/nginx/html/{www,bbs} -p
for name in www bbs;do echo "$(hostname) $name.etiantian.org" >/application/nginx/html/$name/oldboy.html;done
for name in www bbs;do cat /application/nginx/html/$name/oldboy.html;done
: ,
curl -H host:www.etiantian.org 10.0.0.7/oldboy.html
web01 www.etiantian.org
curl -H host:bbs.etiantian.org 10.0.0.7/oldboy.html
web01 bbs.etiantian.org
curl -H host:www.etiantian.org 10.0.0.8/oldboy.html
web02 www.etiantian.org
curl -H host:bbs.etiantian.org 10.0.0.8/oldboy.html
web02 bbs.etiantian.org
curl -H host:www.etiantian.org 10.0.0.9/oldboy.html
web03 www.etiantian.org
curl -H host:bbs.etiantian.org 10.0.0.9/oldboy.html
web03 bbs.etiantian.org
②. 부하 균형 서버 배치
: nginx
mkdir /server/tools -p
cd /server/tools
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar xf nginx-1.12.2.tar.gz
yum install -y pcre-devel openssl-devel
useradd -M -s /sbin/nologin www
cd nginx-1.12.2
./configure --prefix=/application/nginx-1.12.2 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
make && make install
ln -s /application/nginx-1.12.2 /application/nginx
/application/nginx/sbin/nginx
netstat -lntup|grep nginx
: nginx
grep -Ev "#|^$" nginx.conf.default >nginx.conf
:http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream
Syntax: upstream name { ... }
Default: —
Context: http
eg:
upstream oldboy {
server 10.0.0.7:80;
server 10.0.0.8:80;
server 10.0.0.9:80;
}
:upstream web
:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
Syntax: proxy_pass URL;
Default: —
Context: location, if in location, limit_except
eg:
location / {
proxy_pass http://oldboy;
}
:proxy_pass upstream
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream oldboy {
server 10.0.0.7:80;
server 10.0.0.8:80;
server 10.0.0.9:80;
}
server {
listen 80;
server_name localhost;
root html;
index index.html index.htm;
location / {
proxy_pass http://oldboy;
}
}
}
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx -s reload
:
1)
hosts , windows hostname 10.0.0.5 。
http://www.etiantian.org/oldboy.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
간단! Certbot을 사용하여 웹 사이트를 SSL(HTTPS)화하는 방법초보자가 인프라 주위를 정돈하는 것은 매우 어렵습니다. 이번은 사이트를 간단하게 SSL화(HTTP에서 HTTPS통신)로 변경하는 방법을 소개합니다! 이번에는 소프트웨어 시스템 Nginx CentOS7 의 환경에서 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.