ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 开启模块 去掉httpd.conf中的注释 ``` LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so ``` ## 配置 ### 在虚拟主机汇中配置 适合用在单个域下 ``` <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@dummy-host.example.com ServerName 127.0.0.1 ProxyRequests Off ProxyPreserveHost On <Proxy *> Require all granted </Proxy> ProxyPass /support http://192.168.1.251:8008/support ProxyPass /gdForestry http://192.168.1.251:9007/gdForestry ProxyPassReverse /support http://192.168.1.251:8008/support ProxyPassReverse /gdForestry http://192.168.1.251:9007/gdForestry ErrorLog "logs/test.localhost-error_log" CustomLog "logs/test.localhost-access_log" common </VirtualHost> ``` ### 配置全局 ``` ProxyPass /cas http://192.168.0.206:9090/cas ProxyPassReverse /cas http://192.168.0.206:9090/cas ``` ## 方法 ### ProxyPass #### 反向代理 ``` <VirtualHost *:8000> DocumentRoot ../ant_universal_10 ServerName default:8000 ErrorLog logs/default-error_log <Directory "../ant_universal_10"> Options FollowSymLinks AllowOverride All Require all granted </Directory> ProxyPass /imapp/depts http://127.0.0.1:8081/imapp/depts </VirtualHost> ``` > 在内部进行代理 ##### 排除无需代理的 ``` ProxyPass /mirror/foo/i ! ProxyPass /mirror/foo http://backend.example.com ``` ### ProxyPassMatch ``` ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com:8000$1 ProxyPassMatch ^/\d{4}-\d{2}-\d{2} http://www.baidu.com/$1 // 把 /2019-10-10 代理到 www.baidu.com/xxxx ``` `http://example.com/foo/bar.gif`,那内部将会转换为这样的请求`http://backend.example.com/foo/bar.gif`。