Apache反向代理设置方法

来源:互联网 发布:mac版的优酷能缓存吗 编辑:程序博客网 时间:2024/05/22 01:42

打开 apache 安装目录的 conf 文件夹(linux 在 /etc/httpd/conf 或者 /usr/local/apache/conf)

打开 httpd.conf

把 

LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_http_module modules/mod_proxy_http.so

前面的注释去掉

在 httpd.conf 最后添上

NameVirtualHost *:80<VirtualHost *:80>ServerName www.truemv.comServerAlias www.truemv.comProxyRequests Off<Proxy http://www.truemv.com>        Options MultiViews    AllowOverride None    Order allow,deny    Allow from all</Proxy>ProxyPass / http://61.191.191.4:9002/ProxyPassReverse / http://61.191.191.4:9002/</VirtualHost><VirtualHost *:80>ServerName img.truemv.comServerAlias img.truemv.comProxyRequests Off<Proxy http://img.truemv.com>        Options MultiViews    AllowOverride None    Order allow,deny    Allow from all</Proxy>ProxyPass / http://61.191.191.4:9003/ProxyPassReverse / http://61.191.191.4:9003/</VirtualHost>

其中
NameVirtualHost *:80
这句话是告诉apache用域名来区分访问来源,apache支持用域名和ip两种,用ip的话,你的机子上的VirtualHost需要绑定多个ip

附录:

<VirtualHost *:9002>ServerName localhostServerAlias localhostDocumentRoot "x:/xxxx/upload/"<Directory "x:/xxxx/upload/">    Options MultiViews    AllowOverride None    Order allow,deny    Allow from all</Directory>RewriteEngine on  RewriteRule ^/artist-(\d+).html$ /artist.php?id=$1  RewriteRule ^/theme-(\d+).html$ /theme.php?themeid=$1  RewriteRule ^/artist-list-(.+).html$ /artist_list.php?tp=$1  RewriteRule ^/theme-list.html$ /theme_list.php</VirtualHost><VirtualHost *:9003>ServerName localhostServerAlias localhostDocumentRoot "x:/xxxx/mv_img/"<Directory "x:/xxxx/mv_img/">    Options MultiViews    AllowOverride None    Order allow,deny    Allow from all</Directory></VirtualHost>AddType video/x-flv .flv<VirtualHost *:9004>ServerName localhostServerAlias localhostDocumentRoot "x:/xxxx/vod/"<Directory "x:/xxxx/vod/">    Options MultiViews    AllowOverride None    Order allow,deny    Allow from all</Directory></VirtualHost><VirtualHost *:9005>ServerName localhostServerAlias localhostDocumentRoot "x:/xxxx/vod2/"<Directory "x:/xxxx/vod2/">    Options MultiViews    AllowOverride None    Order allow,deny    Allow from all</Directory></VirtualHost><VirtualHost *:9006>ServerName localhostServerAlias localhostDocumentRoot "x/truemv_wap/"<Directory "x:/truemv_wap/">    Options MultiViews    AllowOverride None    Order allow,deny    Allow from all    DirectoryIndex index.php</Directory></VirtualHost><VirtualHost *:9007>ServerName localhostServerAlias localhostDocumentRoot "x:/xxx/xxx/"<Directory "x:/xxx/xxx/">    Options MultiViews    AllowOverride None    Order allow,deny    Allow from all    DirectoryIndex index.php</Directory></VirtualHost><VirtualHost *:9008>ServerName localhostServerAlias localhostDocumentRoot "x:/xxxx/xxx/"<Directory "x:/xxxx/xxx/">    Options MultiViews    AllowOverride None    Order allow,deny    Allow from all    DirectoryIndex index.php</Directory></VirtualHost>


0 0
原创粉丝点击