By cyril950943
Currently my wordpress blog (hosted on DO) is displayed at blog.mydomain.com and I am trying to display it on mydomain.com/blog. mydomain.com is an heroku application (node) so I set up a proxy using express-http-proxy with the following (on the heroku side):
app.use('/blog', proxy('blog.mydomain.com', {
forwardPath: function(req, res) {
return require('url').parse(req.url).path;
}
}));
ON DO’s side, I have changed the wordpress home url and site url in the wp-config.php like so:
define('WP_HOME','http://www.mydomain.com/blog');
define('WP_SITEURL','http://www.mydomain.com/blog');
My blog displays well on mydomain.com/blog but I can’t seem to login on the wordpress admin page (/wp-admin), I always get the error:
ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.
Of course my cookies are enabled and I tried different browsers . I am sure I am missing something but I can’t figure it out. Do you have any ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
It sounds like that the proxy could be dropping the cookies when passing on requests. express-http-proxy has a preserveHostHdr setting that will make sure the host HTTP headers are passed along. Doing some testing, this seems to work quite well:
var express = require('express');
var app = express();
var proxy = require('express-http-proxy');
app.get('/', function (req, res) {
res.send('Oh, hai!');
});
app.use('/blog', proxy('my.ip.addr', {
preserveHostHdr: true,
forwardPath: function(req, res) {
console.log('Proxying to ' + req.url)
return require('url').parse(req.url).path;
}
}));
app.listen(80, function () {
console.log('Listening on port 80!');
});
Using this, I am successfully able to login to the wp-admin panel.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.