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

StackOverflow https://stackoverflow.com/questions/15364267

  •  23-03-2022
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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

OTHER TIPS

Define WP_SITEURL and WP_HOME in wp-config.php to point to the proxy url.

eg.,

define('WP_SITEURL', 'http://example.com/blog/');
define('WP_HOME', 'http://example.com/blog/');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top