Apache 代理(Proxy)
来源:互联网 发布:软件开发是什么 编辑:程序博客网 时间:2024/04/29 21:34
代理分为:正向代理(Foward Proxy)和反向代理(Reverse Proxy)
1、正向代理(Foward Proxy)
正向代理(Foward Proxy)用于代理内部网络对Internet的连接请求,客户机必须指定代理服务器,并将本来要直接发送到Web服务器上的http请求发送到代理服务器,由代理服务器负责请求Internet,然后返回Internet的请求给内网的客户端。
Internal Network Client ——(request-url)——> Foward Proxy Server ———— > Internet
2、反向代理(Reverse Proxy)
反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客户端,此时代理服务器对外就表现为一个服务器。如图:
/————> Internal Server1
Internet ————> Reverse Proxy Server ————> Internal Server2
\————> internal serverN
Apache 代理
apache支持正向代理和反向代理,但一般反向代理使用较多。
- #正向代理
- # 正向代理开关
- ProxyRequests On
- ProxyVia On
- <Proxy *>
- Order deny,allow
- Deny from all
- Allow from internal.example.com
- </Proxy>
- # Reverse Proxy
- # 设置反向代理
- ProxyPass /foo http://foo.example.com/bar
- # 设置反向代理使用代理服务的HOST重写内部原始服务器响应报文头中的Location和Content-Location
- ProxyPassReverse /foo http://foo.example.com/bar
注意:ProxyPassReverse 指令不是设置反向代理指令,只是设置反向代理重新重定向(3xx)Header头参数值。
举例:
下面是典型的APACHE+TOMCAT负载均衡和简单集群配置
- ProxyRequests Off
- ProxyPreserveHost on
- ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=Off
- ProxyPassReverse / balancer://cluster/
- <Proxy balancer://cluster>
- BalancerMember http://localhost:8080 loadfactor=1 retry=10
- BalancerMember http://localhost:8081 loadfactor=1 retry=10
- ProxySet lbmethod=bybusyness
- </Proxy>
ProxyPassReverse / balancer://cluster/ 表示负载均衡配置中的所有TOMCAT服务器,如果响应报文的Header中有Location(3xx指定重定向的URL)或Content-Location(指定多个URL指向同一个实体),则使用请求报文中HOST替换URL中的HOST部分。
- GET http://apache-host/entityRelativeUrl
- tomcat response 307 ,Header Location: http://localhost:8080/entityRelativeUrl
- apache 重写 response header中的Location为:http://apache-host:8080/entityRelativeUrl
注意:只有TOMCAT RESPINSE Location中的URL的Host部分匹配tomcat原始HOST的情况才重写。如307到http://localhost:8088/entityRelativeUrl是不会重写的。
文章转载自:http://acooly.iteye.com/blog/1337414
- Apache 代理(Proxy)
- Apache 代理(Proxy) 转发请求
- Apache反向代理(mod-proxy方式)
- apache 的http代理出错 502 Proxy Error
- apache的http代理出现 502 Proxy Error
- 代理(Proxy)
- Proxy 代理
- Proxy 代理
- Proxy代理
- 代理proxy
- 代理(Proxy)
- 代理Proxy
- apache proxy
- Apache Proxy and WebLogic Proxy
- JDK Proxy代理&CGLIB代理
- java Proxy代理&cglib代理
- 使用Apache的Proxy模块实现对被代理网站的访问
- Apache commons Proxy简介和动态代理、动态拦截器实现
- stringstream的使用方法
- 编译自己的 Code::Blocks ! (二)安装基础工具
- 【C语言基础】C语言第二章
- 求HX-3000升级包
- Dynamic Performance Tables not accessible
- Apache 代理(Proxy)
- JAR包介绍大全用途作用详解JAVA
- 二分图匹配---- 二分的真谛
- ls -l |grep "^-"|wc -l 程序问题的定位—strace -p pid(跟踪系统调用)gdb -p pid(调试)lsof -p pid(查看当前进程打开的文件描述符) ps -e
- 字节、字、位、比特,这四者之间的关系
- Struts2 带参数跳转
- 设置input file的样式
- jsp面试题
- Java 的内存泄漏