咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
windows下使用apache搭建反向代理
1、安装Apache,并使其能正常工作
2、打开httpd.conf,找到以下几个Module并将其启用(如果没有,可以自行添加)
mod_proxy.so(module_proxy) mod_proxy_http.so(module_proxy_http) mod_cache.so(module_cache) mod_disk_cache.so(module_disk_cache)
3、参考以下VirtualHost段,进行设置:
<VirtualHost *:8081> ServerName 10.75.123.1 //本地服务器内网地址 ProxyPass /test http://www.landui.com:8080/test ProxyPassReverse /test http://www.landui.com:8080/test ProxyPass /testm http://www.landui.com:8089/testm ProxyPassReverse /testm http://www.landui.com:8089/testm #下面这几段可以加也可不加,看需求 # CacheRoot "d:/apache_cache/" # CacheEnable disk /images/ # CacheDirLevels 2 # CacheDirLength 1 </VirtualHost>
其中,ProxyPass和ProxyPassReverse代表原始地址,CacheRoot为缓存目录,需要自行建立,并给Apache进程所在的用户分配NTFS权限,CacheEnable后的第一个参数disk表示用磁盘进行缓存,/images/ 表示需要缓存的目录,如果直接设置为/,可能导致动态脚本被缓存,那就失去了本身的意义。可以添加多个CacheEnable以缓存多个目录。CacheDirLevels和CacheDirLength一般不需要修改,这个表示缓存目录中数据目录的级数和目录名长度。