【发布时间】:2013-02-28 03:29:30
【问题描述】:
我想代理托管在 localhost 的 8888 端口的 Wordpress。
当我按如下方式 http://localhost:8001/ 访问此节点-http-proxy 时,它会重定向到 http://localhost:8888/。我的意思是 Wordpress 会进行重定向,因为 Wordpress 认为它在端口 8888 上。
我怎样才能正确地反向代理?
var util = require('util'),
http = require('http'),
httpProxy = require('http-proxy');
//
// Create a new instance of HttProxy to use in your server
//
var proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 8888
});
}).listen(8001);
这个问题有帮助吗? https://github.com/nodejitsu/node-http-proxy/pull/376 但是不明白怎么用。
【问题讨论】:
-
您找到解决方案了吗?我正在尝试使用 nginx 作为反向代理进行类似的设置,而 WordPress 重定向正在搞砸一切。