apache 代理 proxy使用

浏览次数:253

编译时依然使用2.2/2.4基础标准,apr、apr-util、pcre需要安装
./configure--prefix=/opt/sudytech/apache2 --enable-so --enable-mods-shared=most--with-mpm=worker --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util--with-pcre=/usr/local/pcre/bin/pcre-config --enable-ssl--with-ssl=/usr/local/openssl --with-included-apr --enable-proxy=shared--enable-proxy-ajp=shared --enable-proxy-balancer=shared--enable-speling=shared

添加虚拟主机时,需注意proxypass后IP需有/结尾
此例为.51代理显示.126内容(含cookie传递)

<VirtualHost*>
ServerName     170.18.20.51   
ProxyRequestsOff
<Proxy*>
    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Proxy>
SetEnvforce-proxy-request-1.0.1
SetEnvproxy-nokeepalive 1
ProxyPass                  /        http://170.18.20.126/
ProxyPassReverse   /        http://170.18.20.126/
ProxyPassReverseCookieDomain    170.18.20.126 170.18.20.51
ProxyPassReverseCookiePath /        /
</VirtualHost>