httpd反向代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
23、反向代理功能(httpd目前只能支持一台后端服务器)
启用/反向代理
    ProxyPass "/" "http://www.example.com/"
    ProxyPassReverse "/" "http://www.example.com/"
特定URL反向代理
    ProxyPass "/images" "http://www.example.com/"
    ProxyPassReverse "/images" http://www.example.com/
示例:
    <VirtualHost *>
     ServerName www.magedu.com
     ProxyPass / http://localhost:8080/
     ProxyPassReverse / http://localhost:8080/
    </VirtualHost>
 
 
     
proxy_http_module模块代理配置
ProxyRequests:      Off关闭正向代理。
ProxyPass:          反向代理指令
ProxyPassReverse:   保留代理的response头不重写(个别除外)
ProxyPreserveHost:  On开启。让代理保留原请求的Host首部转发给后端服务器
ProxyVia:           On开启。代理的请求响应时提供一个response的via首部
 
启用反向代理
ProxyPass "/" "http://www.example.com/"
ProxyPassReverse "/" "http://www.example.com/"
特定URL反向代理
ProxyPass "/images" "http://www.example.com/"
ProxyPassReverse "/images" http://www.example.com/ 
 
     
<VirtualHost *:80>
     ServerName www.zjol.com
     ProxyRequests Off
     ProxyVia On
     ProxyPreserveHost On
     ProxyPass / http://127.0.0.1:8080/
     ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
 
 
测试ProxyPreserveHost选项:当后端出现多个"主机" 
一.是IP访问的主机(没有ServerName),如果ProxyPreserveHost是Off的,转发给tomcat就没有域名首部,只有IP地址,那么将只能访问node1.magedu.com主机,反之为on,访问localhost主机
二.是域名访问主机(有ServerName),如果ProxyPreserveHost是Off的,那么将访问node1.magedu.com主机,反之为on,访问localhost主机
<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">   </Host>
<Host name="node1.magedu.com"  appBase="/data/webapps/" unpackWARs="true" autoDeploy="true">
    <Context path="/test" docBase="/data/test" reloadable="false" />
    <Context path="/test1" docBase="" reloadable="false" />
</Host>  
    

  

posted @   yuanbangchen  阅读(408)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示