Apache反向代理设置方法

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

打开 httpd.conf

把 

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

前面的注释去掉

在 httpd.conf 最后添上

NameVirtualHost *:80


ServerName www.truemv.com
ServerAlias www.truemv.com
ProxyRequests Off

        Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

ProxyPass / http://61.191.191.4:9002/
ProxyPassReverse / http://61.191.191.4:9002/



ServerName img.truemv.com
ServerAlias img.truemv.com
ProxyRequests Off

        Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

ProxyPass / http://61.191.191.4:9003/
ProxyPassReverse / http://61.191.191.4:9003/

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

附录:


ServerName localhost
ServerAlias localhost
DocumentRoot "x:/xxxx/upload/"

    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all

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



ServerName localhost
ServerAlias localhost
DocumentRoot "x:/xxxx/mv_img/"

    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all




AddType video/x-flv .flv


ServerName localhost
ServerAlias localhost
DocumentRoot "x:/xxxx/vod/"

    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all




ServerName localhost
ServerAlias localhost
DocumentRoot "x:/xxxx/vod2/"

    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all




ServerName localhost
ServerAlias localhost
DocumentRoot "x/truemv_wap/"

    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    DirectoryIndex index.php




ServerName localhost
ServerAlias localhost
DocumentRoot "x:/xxx/xxx/"

    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    DirectoryIndex index.php




ServerName localhost
ServerAlias localhost
DocumentRoot "x:/xxxx/xxx/"

    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
    DirectoryIndex index.php



你可能感兴趣的:(服务器)