8、nginx和tengine简介

练习:

(1) root为同一路径;

(2) root为不同的路径;

location \.php$ {

root /web/app/wp;

}

location / {

root /web/htdocs;

}

如何解决问题?

(3) fpm server为另一主机;

扫描二维码关注公众号,回复: 4289762 查看本文章

location \.php$ {

fastcgi_pass fastcgi://172.16.100.9:9000;

}

location / {

root /web/htdocs;

}

总结:

cache:

proxy_cache

fastcgi_cache

练习:

使用nginx反向代理(rr调度)用户请求至两个以上的后端LAMP(按标准路径部署的有pma);

(1) 手动更新所有节点上的pma至新版本;

(2) 写脚本实现如上过程;

回顾:nginx upstream, fastcgi

upstream name {

server

server

}

wrr

ip_hash|least_conn|sticky

fastcgi_pass fastcgi://

LNMMP: Memcached

HAProxy:

web arch: haproxy

mode: http, tcp (https, mysql)

HAProxy:

代理(http): 掮客(broker)

正向代理

反向代理:

代理作用:web缓存(加速)、反向代理、内容路由(根据流量及内容类型等将请求转发至特定服务器)、转码器;

在代理服务器上添加Via首部;

缓存的作用:

减少冗余内容传输;

节省带宽、缓解网络瓶颈;

降低了对原始服务器的请求压力;

降低了传输延迟;

HAProxy: 只是http协议的反向代理,不提供缓存功能;但额外支持对tcp层对基于tcp通信的应用做LB;

nginx:

server {

}

server {

location ~* \.php$ {

proxy_pass

}

location / {

}

}

upstream {

leastconn

server

server

}

upstream {

}

haproxy:

frontend

use_backend

default_backend

backend

balancer

server

server

listen:

server

default

配置文件:haproxy.cfg

全局配置

代理配置

回顾:

HAProxy:

http协议反向代理

tcp层的LB

特性:event-driven, ebtree

配置:/etc/haproxy/haproxy.cfg

/usr/sbin/haproxy

CentOS 6: /etc/rc.d/init.d/haproxy

CentOS 7: haproxy.service

配置分为两段:

global

配置参数:log, maxconn, ...

proxies

defaults, frontend, backend, listen

示例:

frontend main *:80

default_backend websrvs

backend websrvs

balance roundrobin

server web1 172.16.100.68 check 

server web2 172.16.100.69 check

 

 

 

 

 

 

nihoa 

 

猜你喜欢

转载自www.cnblogs.com/hanshanxiaoheshang/p/10038673.html