您的位置:首页 > 运维架构 > Nginx

利用nginx实现域名隐藏真实地址实现域名重定向

2011-04-02 15:30 543 查看
效果是当访问a.haowan.com/xxxxx时,请求的真实路径是 b.haowan.com/a/xxxxx

server
{
listen 80;
server_name a.haowan.com;
index index.php index.html index.htm;
root /data/www/a;

location ~ ^/a/
{
proxy_redirect off;
proxy_set_header Host b.haowan.com;
proxy_pass http://192.168.10.10:80;
}
location /
{

set $domain default;
if ( $http_host ~* "^(.*)\.haowan\.com")
{
set $domain $1;
}
rewrite ^/(.*) /$domain/$1 last;
}
}

server
{

listen 80;
server_name b.haowan.com;
index index.php index.html;
root /data/www/b;
location / {
index index.html index.php;
}
}
原文链接:http://bbs.linuxtone.org/thread-9384-1-1.html 本文出自 “openpy” 博客,请务必保留此出处http://openpy.blog.51cto.com/2798268/1572391
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: