Rails app – reverse proxy to Heroku Blog – Works Admin page, but redirects to original on others. How to fix?

I have a rails 4.0 app, running on heroku, w/ SSL configured. I also have a heroku hosted wordpress blog. I’m attempting to use this rack-reverse-proxy gem

I used the following as guidance: http://rywalker.com/setting-up-a-wordpress-blog-on-heroku-as-a-subdirectory-of-a-rails-app-also-hosted-on-heroku
ro
It works on the wp-admin page, but whenever I want to go to an actual blog page it’ll redirect to the original blog.herokuapp.com website instead of displaying the herokuapp.com/blog url

Read More

I’ve been stuck on this and can’t seem to find my error. Below is my code:

config.ru

require ::File.expand_path('../config/environment',  __FILE__)


use Rack::ReverseProxy do
  reverse_proxy(/^/blog(/.*)$/,
    'http://blog.herokuapp.com/$1', opts = {:preserve_host => true})
end

run Rails.application

routes

get "/blog" => redirect("/blog/") 

Also here’s the beginning of my log file for the redirect that works

Jul 24 08:09:44 heroku/router:  at=info method=POST path="///wp-admin/admin-ajax.php"    host=blog.herokuapp.com request_id=5816837a-4c92-4da8-90aa-facbc7179858 fwd="54.91.255.133" dyno=web.1 connect=1 service=91 status=200 bytes=1353 

Here’s the router that doesn’t work and does a 301 redirect to the original

Jul 24 08:08:38 heroku/router:  at=info method=GET path="///" host=blog.herokuapp.com request_id=2eabd176-aa62-473a-8b56-9b0b02b05c18 fwd="54.91.255.133" dyno=web.1 connect=0 service=92 status=301 bytes=2041 
Jul 24 08:08:39 heroku/router:  at=info method=GET path="/" host=blog.herokuapp.com  request_id=eb7bcc80-b675-4081-884c-a0f5d801b34b fwd="184.74.164.250" dyno=web.1 connect=1 service=13-5 status=200 bytes=805 

Any help would be greatly appreciated!!!

EDIT: Removed an extra / (didn’t help though)
http://blog.herokuapp.com//$1′

to
‘htto://blog.herokuapp.com/$1’

Related posts

Leave a Reply