I'm using the node module node-http-proxy to redirect specific virtual hosts to Apache for a couple of WordPress sites. My Node 'server' listens on port 80, and redirects to SOME_OTHER_PORT which Apache is listening on.
It works fine (when I change the WordPress settings to account for SOME_OTHER_PORT as per suggestions from users). But the port number is always included in the URL for every page on the WordPress sites. Is there any other way of doing this such that I don't have to see these ugly port numbers?
I can't imagine this would be possible without a considerable change in my setup, but I thought it would be worth asking.
Here's the code I use for proxying in node:
// Module dependancies
var httpProxy = require('http-proxy'),
express = require('express')(),
connect = require('connect');
// Http proxy-server
httpProxy.createServer(function (req, res, proxy) {
// Host Names and Ports
var hosts = [
'www.some-website.co.uk'
];
// Ports
var ports = [
8000
];
var host = req.headers.host;
var port = hosts.indexOf(host) > -1 ? ports[hosts.indexOf(host)] : 9000;
// Now proxy the request
proxy.proxyRequest(req, res, {
host: host,
port: port
});
})
.listen(80);
Port 80
is where all my traffic comes. Port 8000
is a potential WordPress site sat behind an Apache server. Port 9000
is a potential Node app listening elsewhere.
Any insight as to whether this is a shoddy way to do it would also be welcome.