Rails heroku application with wordpress as a subfolder unable to log in to the admin

I have a rails application running on Heroku and I am trying to create a Wordpress blog configured on / blog for my domain for SEO purposes. I have Rack :: ReverseProxy installed in my rails application pointing to the blog subdomain, and you have all the configuration on the Wordpress side, so all css and links work correctly. The problem I am facing is that when I go to / blog / wp-admin, I redirect to / blog / wp -login? Redirect_to = {blogdomain_domain} & reauth = 1, and after trying to log in I was sent to the same page.

I noticed that I am not trying to log in, even though the Wordpress Test Cookie is configured for the correct domain. I even traced it in wp-includes / pluggable.php in wp_set_auth_cookie, where it actually sets a cookie after a successful login, setcookie calls return true, but immediately after cookies are not added to my session (even despite that the test cookie succeeds in the headers)

Am I going in the wrong direction, looking there? Are there any settings that I need to research in order to be able to log in this way?

+4
source share
2 answers

I had this exact problem, and I finally tracked it to an error in the reverse proxy. The set-cookie header is sent in the wrong format, so the browser only correctly interpreted the first cookie. It was a test wordpress cookie. All the rest (useful) were thrown away, so of course I could not enter.

I plan to send the error and branch to rack-reverse-proxy, but at the same time I fixed it with this patch in my config.ru:

class MyReverseProxy < Rack::ReverseProxy private def create_response_headers(http_response) response_headers = super(http_response) if response_headers if response_headers["Set-Cookie"].is_a?(Array) response_headers["Set-Cookie"] = response_headers["Set-Cookie"].join("\n") end end response_headers end end # this is to make /blog show my wordpress blog use MyReverseProxy do reverse_proxy_options :preserve_host => false reverse_proxy(/^\/blog(\/.*)$/, 'http://your-blog-server.com$1') end 
+1
source

I have no answer, but I have some tips to better understand what is happening.

If you use Google Chrome, open the Network panel of the developer tools and see what happens when you log in.

Check which domain cookies are configured in, when you look at the response headers for a POST request that processes your login, you should see Set-Cookie headers, check if these domains are .domain domain. com or blog.domain.com and see if this request tries to redirect you to another place.

Another possibility is that your Wordpress installation may be configured differently than you want, for example, the website URL: www.domain.com/blog, not blog.domain.com

Is it possible for you to visit the login page at blog.domain.com/wp-admin/?

0
source

All Articles