Report this

What is the reason for this report?

Problem login in on 1-click Wordpress install after using proxy

Posted on June 7, 2015

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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.