网站首页 > 技术教程 正文
正向代理指的是客户端的
反向代理指的是服务端的
需要实现的反向代理:
1、首先使用SwitchHosts配置不同域名,如下:(SwitchHosts软件在上一篇博客有链接)
2、在Linux上部署两台tomcat服务器:(一个用于sina,一个用于sohu)
①
②
3、按要求sina是8080的,sohu是8081的,所以sina就用默认的,修改apache-sohu的配置文件(配置文件是apache-sohu目录下-->conf-->server.xml):
提示:主要修改port端口号,如下:
①
②
③
4、修改完成之后,启动两个tomcat,访问一下192.168.1.141:8080和192.168.1.141:8081:
5、为了以示区别,现在分别修改apache-sina和apache-sohu目录下的webapps下的ROOT下的index.jsp:
找到h1:
①
②
再次访问(改了jsp后直接刷新即可):
①
②
6、修改nginx.conf配置文件:
如下:
upstream sina{ server 192.168.1.141:8080; } server { listen 80; server_name www.sina.com.cn; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass(请求转发到sina,sina又指向192.168.1.141:8080,所以访问www.sina.com.cn就会直接访问192.168.1.141:8080) http://sina; index index.html index.htm; } } upstream sohu{ server 192.168.1.141:8081; } server { listen 80; server_name www.sohu.com; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://sohu; index index.html index.htm; } }
7、重新加载nginx
8、重新访问:
①
②
成功实现反向代理!!!!
猜你喜欢
- 2024-10-17 让ChatGPT帮我一步步配置nginx正向代理
- 2024-10-17 彻底理解正向代理、反向代理、透明代理
- 2024-10-17 nginx正向代理配置(nginx的正向代理和反向代理)
- 2024-10-17 使用 nginx来搭建正向代理服务器(nginx做正向代理)
- 2024-10-17 理解什么是正向代理?反向代理?(正反向代理区别)
- 2024-10-17 正向代理和反向代理(正向代理和反向代理的例子)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)