tengine反向代理
什么是反向代理?
1 | 什么是反向代理? |

反向代理如何配置?
1 | 查看tengine文档 |
1.安装tomcat
1.1.安装ip为192.168.230.10的主机的tomcat
1 | [root@node1 software]# tar -zxvf apache-tomcat-7.0.61.tar.gz -C /opt/modules |
1 | <html> |
1 | 进入tomcat目录 |

1.2.安装ip为192.168.230.11的主机的tomcat
1 | [root@node2 software]# tar -zxvf apache-tomcat-7.0.61.tar.gz -C /opt/modules |
1 | <html> |
1 | [root@node2 ROOT]# cd /opt/modules/apache-tomcat-7.0.61/bin |

2.配置nginx访问禁止允许
1 | 进入tengine的conf目录下 |
2.1.编辑nginx.conf文件
1 | [root@node1 conf]# vi nginx.conf |
查看nginx访问禁止配置是否成功
1 | 在地址栏输入:http://192.168.230.10/ |

1 | 在地址栏输入:http://192.168.230.18/ |

3.配置nginx用户认证
1 | 用户认证访问 |
3.1.使用yum安装httpd
1 | [root@node1 ~]# yum install httpd |
3.2.编辑nginx.conf文件
1 | [root@node1 conf]# vi nginx.conf |
1 | Apache发行包中的htpasswd命令来创建user_file 文件 |

1 | 在浏览器地址栏中输入:http://192.168.230.10/ |

1 | 身份认证成功页面显示: |

4.配置nginx访问状态监控
1 | 进入tengine的conf目录 |
1 | [root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf |
1 | 编辑nginx.conf文件 |

1 | 在浏览器地址栏中输入:http://192.168.230.10/status |

5.配置nginx反向代理
1 | [root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf |
5.1.重新加载nginx服务
1 | [root@node1 init.d]# service nginx reload |
1 | 在地址行输入检查页面是否能正常显示:http://192.168.230.10/ |

6.配置nginx负载均衡
1 | 1.保证192.168.230.10:8080.192.168.230.11:8080都能正常运行 |

6.1.重新启动nginx服务
1 | [root@node1 init.d]# service nginx stop |
1 | 2.在地址行输入检查页面是否能正常显示:http://192.168.230.10/ |

1 | 在访问一次显示: |

7.tengine新增健康检查模块
1 | [root@node1 ~]# cd /opt/modules/tengine-2.1.0/conf |

1 | 2.在地址行输入:http://192.168.230.10/status对tomcat服务器进行健康检查 |

1 | 重新启动两台tomcat |

本文作者 : Matrix
原文链接 : https://matrixsparse.github.io/2016/10/02/tengine反向代理/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
知识 & 情怀 | 二者兼得