Question

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

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?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.