Search code examples
node.jsnode-http-proxy

How can I proxy Wordpress with node-http-proxy, my wordpress redirects to a different port


I want to proxy my Wordpress which is hosted at localhost at port 8888.

When I http to this node-http-proxy as follows http:// localhost:8001/ it re-directs to http:// localhost:8888/. I mean that Wordpress does the re-direct because Wordpress thinks its on port 8888.

How can I reverse proxy this correctly?

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);

Does this issue help? https://github.com/nodejitsu/node-http-proxy/pull/376 but I don't understand how to use it.


Solution

  • I suspect you need to go into your wordpress admin settings and set the site URL parameter to http://localhost:8001.