nginx反向代理概述及部署

  

1。反向代理概述

反向代理(反向代理)方式是指以代理云服务器来接受互联网上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给互联网上请求连接的客户端,此时代理服务器对外就表现为一个反向代理服务器。

环境准备:

主机名IP地址角色系统web-node1.cometh0:192.168.90.201web-node1节点CentOS7.2web-node2.cometh0:192.168.90.202web-node2节点CentOS7.2lb-node1.cometh0:192.168.90.203Nginx反向代理CentOS7.2

2.节点节点部署

在两台web-node节点中均使用Yum安装一个Apache用于做真实机,监听8080端口

web-node1.com部署

 nginx反向代理概述及部署

 [root@web-node1  ~] #, rpm  -ivh  http://mirrors.aliyun.com/epel/epel最新-释放- 7. noarch.rpm
  (root@web-node1  ~) #, yum  install  -y  gcc  glibc  gcc-c + +, make  screen  tree  lrzsz
  # #部署web-node1  httpd服务
  (root@web-node1  ~) #, yum  install  -y  httpd
  (root@web-node1  ~) #, sed 小姐;& # 39;s/Listen  80/Listen  8080/舌鳎# 39;,/etc/httpd/conf/httpd . conf
  (root@web-node1  ~) #, systemctl  start  httpd
  (root@web-node1  ~) #, echo “web-node1.com",祝辞,/var/www/html/index . html
  (root@web-node1  ~) #, curl  http://192.168.90.201:8080
  web-node1.com 

web-node2.com部署

 [root@web-node1  ~] #, rpm  -ivh  http://mirrors.aliyun.com/epel/epel最新-释放- 7. noarch.rpm
  (root@web-node1  ~) #, yum  install  -y  gcc  glibc  gcc-c + +, make  screen  tree  lrzsz
  # #部署web-node2  httpd服务
  (root@web-node1  ~) #, yum  install  -y  httpd
  (root@web-node1  ~) #, sed 小姐;& # 39;s/Listen  80/Listen  8080/舌鳎# 39;,/etc/httpd/conf/httpd . conf
  (root@web-node1  ~) #, systemctl  start  httpd
  (root@web-node1  ~) #, echo “web-node2.com",祝辞,/var/www/html/index . html
  (root@web-node1  ~) #, curl  http://192.168.90.202:8080
  web-node2.com 

3。反向代理部署

Nginx源码编译安装,使其支持4层,并监听80端口

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

3.1配置Nginx7层反向代理


<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

测试代理

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

2。通过分组方式,以及用户代理实现不同代理

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<李>

<代码>

<>之前,,#需要配置本地主机解析测试   ,,,,,,,server  {   ,,,,,,,,,,,,,,,listen  80;   ,,,,,,,,,,,,,,,server_name  nginx.jiege.com;   ,,,,,,,的位置/,{   ,,,,,,,if  (http_user_agent 美元;~ *,“Firefox") {   ,,,,,,,,,,,,,,,,,,,proxy_pass  http://static-cluster;   ,,,,,,,,,,,,,,,,,,,}   ,,,,,,,if  (http_user_agent 美元;~ *,“Chrome"), {   ,,,,,,,,,,,proxy_pass  http://dynamic-cluster;   ,,,,,,,,,,,}   ,,,,,,,proxy_pass  http://default-cluster;   ,,,,,,,,,,,}   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

nginx反向代理概述及部署