Chinaunix
标题:
nginx 取重写前的主机名
[打印本页]
作者:
凝望长空
时间:
2011-09-18 20:36
标题:
nginx 取重写前的主机名
nginx 取重写前的主机名
请教大家一个问题,怎么让nginx来取重写前的主机名
nginx A主机配置:
server {
listen 7070;
server_name
www.a.com
;
access_log /data/logs/nginx/
www.abc123.com.access.log
main;
error_log /data/logs/nginx/
www.abc123.com.error.log
;
location ~* /.*$ {
expires -1s;
rewrite ^(.*)$
http://www.b.com
$1;
break;
}
-----------------------------------------
nginx B主机:
############ IP ###########
server {
listen 7070;
server_name
www.b.com
;
access_log /data/logs/nginx/www.b.com.access.log main;
error_log /data/logs/nginx/www.b.com.error.log;
location / {
expires -1s;
if ( $host = "www.a.com" ) {
proxy_pass
http://192.168.1.122:8801
;
break;
}
if ( $host = "www.c.com" ) {
proxy_pass
http://192.168.1.122:8802
;
break;
}
}
}
现在访问
www.a.com
跑到了nginx B主机的nginx的index.html了,我想的是访问
www.a.com
能转到nginx B主机的
http://192.168.1.122:8801
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2