2020-07-03 架構(gòu)師第2周作業(yè)

▲單獨(dú)架構(gòu)的小伙伴看這里:(學(xué)習(xí)杰哥視頻的作業(yè)第3-4天)

1、編譯安裝tengine,配置虛擬主機(jī),實現(xiàn)api.x.com代理9001端口

1.1 準(zhǔn)備源碼

http://tengine.taobao.org/download.html 找到下載包并且下載(Tengine-2.2.0.tar.gz)

1.2 編譯安裝

# tar-xvf tengine-2.2.0.tar.gz

#./configure--prefix=/apps/tengine--user=nginx--group=nginx--with-http_ssl_module--with-http_v2_module--with-http_realip_module--with-http_stub_status_module--with-http_gzip_static_module--with-pcre--add-module=/root/echo-nginx-module

# make&&make install

1.3 配置代理

# vim /apps/tengine/conf/conf.d/9001.conf

server{

? ? listen 9001;

? ? server_name api.x.com;

}


2、配置haproxy,實現(xiàn)7層代理。/a 代理路徑轉(zhuǎn)發(fā)到a集群;/b 代理路徑轉(zhuǎn)發(fā)到b集群

2.1 編譯安裝haproxy

# tar xvf haproxy-1.8.20.tar.gz?

# make ARCH=x86_64 TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_SYSTEMD=1 \ USE_CPU_AFFINITY=1 PREFIX=/apps/haproxy

# make install PREFIX=/apps/haproxy

2.2 haproxy添加代理配置

# cat /etc/haproxy/haproxy.cfg

global

maxconn 100000

chroot /apps/haproxy

user haproxy

group haproxy

daemon

nbproc 2

cpu-map 1 0

cpu-map 2 1

log 127.0.0.1 local3 info

defaults

option http-keep-alive

option forwardfor

maxconn 100000

mode http

timeout connect 300000ms

timeout client 300000ms

timeout server 300000ms


#添加haproxy代理配置

listen web_port

bind 192.168.100.101:80

mode http

acl a_path path_beg -i /a

use_backend a_path_host if a_path

acl b_path path_beg -i /b

use_backend b_path_host if b_path


backend a_path_host

mode http

server web1 192.168.100.102:80check inter 2000 fall 3 rise 5

backend b_path_host

mode http

server web1 192.168.100.103:80 check inter 2000 fall 3 rise 5

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容