比较来自世界各地的卖家的域名和 IT 服务价格

nginx: 重定向所有请求的代理,但不是这三个特定的 URL

nginx 有时它可能很困难:

我想要

重定向所有传入请求

www.sub.domain.com/*



www.other.domain.com/*

使用代理让用户仍然看到原始

www.sub.domain.com

观看网站时

为特定添加异常 URL (所有相同类型):

www.sub.domain.com/script

有必要重定向

www.yet.another.domain.com/www.sub.domain.com/new_script

, 通过保持输入的数据 POST 对于脚本。 具有一个包含一个包含的小技巧

new_script

在原始域之后立即命名。

这就是我所做的:


server {
listen xx.xx.xx.xx:80;
root /var/www;
index index.html index.htm;
server_name www.sub.domain.com;


<pre><code> location /cms/ {
proxy_pass [url=http://yy.yy.yy.yy:8080;]http://yy.yy.yy.yy:8080;[/url]
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}

location /script {
proxy_pass [url=http://www.yet.another.domain.com/www.sub.domain.com/;]http://www.yet.another.domain. ... m/%3B[/url]
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}

location / {
proxy_pass [url=http://yy.yy.yy.yy:8080;]http://yy.yy.yy.yy:8080;[/url]
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;

rewrite ^/int/a.([a-zA-Z]+).([0-9]+)$ /site/int/a?l=$1&amp;i=$2 last;
rewrite ^(.*)$ /site/$1 last;
}
</code></pre>


}

当访问时

www.sub.domain.com/script

, 这发生过:


curl -I www.sub.domain.com/script
HTTP/1.1 301 Moved Permanently
Server: nginx/1.6.0
Date: Mon, 04 Aug 2014 04:12:23 GMT
Content-Type: text/html
Content-Length: 184
Location:
<a href="[url=http://www.sub.domain.com/script/"]http://www.sub.domain.com/script/"[/url] rel="nofollow noreferrer">
[url=http://www.sub.domain.com/script/]http://www.sub.domain.com/script/[/url]
</a>
Connection: keep-alive

此外,还显示错误。 404: “找不到:要求 URL /www.sub.domain.com/ 在此服务器上找不到。“

我的错误在哪里? 我无法注意到它。 (或者是一堆错误吗? 我是新的重定向 nginx.)

非常感谢!
已邀请:

要回复问题请先登录注册