在IIS设置了反向代理后,为什么res.redirect会跳转到localhost?
发布于 7 年前 作者 MitchellZhang 4607 次浏览 来自 问答

IIS中某个应用的反向代理的规则是这样的:

                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:3002/{R:0}" />
                </rule>

所以访问localhost/xxx的时候,会去到http://localhost:3002/

然后3002端口上的nodejs程序设置express路由为这样:

var app = express();
app.get('/', function (req, res) {
    res.redirect('http://www.baidu.com/abc/bbb');
});

当我在浏览器输入localhost/xxx的时候,会跳转到localhost/abc/bbb。并没有跳转到http://www.baidu.com/abc/bbb上。 请问这是为什么?

回到顶部