Blank Page Hosting Wordpress in Heroku - ruby-on-rails

I've followed Ry Walker's instructions in Setting up a Wordpress blog on Heroku as a subdirectory of a Rails app also hosted on Heroku.
Everything seemed to work fine at first (I was able to access the Wordpress app through the /blog subdirectory), however after a few minutes I started getting a blank page as result of both /blog and [blog-app].herokuapp.com
I have gone through the steps twice and the same problem persists. Unfortunately, Heroku logs does not show any errors. I am afraid that this is related to the RewriteBase directive.
Has anyone faced similar problem?

I was having a similar problem, and it ended up being related to a bug in the rack-reverse-proxy gem where the content length header was getting corrupted.
There have been two people that have offered up fixes to the gem, but the fixes haven't been merged into the master branch. I forked the branch, copied the fix somebody had suggested, and used my version of the gem in the Gemfile. It's been working great ever since.
Here's the change you'll need to make in lib/rack/reverse-proxy.rb
# ensure content length header is correct
res.content_length = body.bytesize

Related

Rails 4 Heroku - changes not getting pushed?

I am using Heroku to try to deploy a personal Ruby on Rails project and everything was going great until today.
I am very very new to Ruby on Rails and Heroku so please bare that in mind. I am not sure what is causing my issue and therefore not sure what code or information is best to supply so please ask me what you think you need to know to help resolve the issue and I will provide it.
My Ruby on Rails app worked fine both locally and on Heroku until I followed the information here to try and serve static images from Amazons S3 bucket. Note I only went as far as the static assets section.
This appeared to stop my Ruby on Rails application from recognising changes in my code. So I would make a change to a HTML file in my editor but the server was serving up the older version of the HTML file, even restarting the server didn't fix this.
I have been searching the web for hours trying to figure out what has gone wrong.
I deleted everything under public assets and I ran the precompile command:
rake assets:precompile
And this seems to have improved things locally, when I edit a HTML file the changes are reflected on localhost. However when I push to Heroku and go to my application hosted on Heroku it still shows the older HTML file no matter how many changes I make and pushes I do to Heroku.
The HTML files that are not updating are located here:
app/assets/templates
I'm not sure what I may have changed that has caused the HTML files not to get updated on Heroku?? What should I look at and try? What other information would be useful in helping track down the issue?
The answer marked as correct in this StackOverflow question worked for me - Updated CSS Stylesheet not loaded following deployment to Heroku? - It looks like I accidently added assets precompiled file in my git repo somewhere along my development and that caused the issue.

Reverse Proxy with Heroku (for Wordpress) won't show full pages

I am trying to use a reverse proxy to serve a Wordpress blog running on EC2 at /blog from a rails app running on Heroku. I've used the rack-reverse-proxy gem and followed directions like this:
How can I use a subdirectory instead of a subdomain?
My app is running at http://myapp.com, my main target (wordpress) server is running at http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com.
The pages on the target server all serve up fine when accessed directly. However, no matter what page I try to get through the reverse proxy, the HTML gets cut off. I've tried serving via both my own custom builds of Wordpress on Ubuntu (EC2) and on hosted examples like Bluehost. I've tried to access simple, handmade HTML and text test files, as well as the php files automatically generated by wordpress. Every time, the file is cut off.
Text files just get randomly cut off after ~1000 characters (this is variable)
Ditto for hand-coded HTML files
Wordpress files seem to get cutoff during the <head> (often mid-word) and render an empty <body>.
If a page should exist (e.g. http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com/test-post, it will load (at least partially) at myapp.com/blog/test-post, so I don't know that rewrites are the issue.
I've tried enough variables on the wordpress/destination server that I'm inclined to think it's something on the Rails side (I have the same issue whether running "myapp" locally or on a Heroku test server). Beyond that, I'm stuck.
Any thoughts as to what I might be doing wrong? There's nothing in the Apache logs to indicate that anything is getting cut off. I'm pounding my head over this to no avail, and would really appreciate any help.
FIXED IT!
Digging into the rack-reverse-proxy gem, I found that I'm not the only person that had an issue with this:
Seeing some issues with Content-Length being corrupted, this ensures it matches body length as delivered.
The fix hasn't been merged into the master branch, but I forked my own copy, applied the fix, and it's working great. Hopefully it'll be merged into the master and nobody else will have to worry about this.
EDIT
One more thing that might be helpful for somebody else, if they are having problems with Visual Editing Mode not working under wordpress: Make sure that you also include this update to have the headers get passed in properly. The gem just hasn't really been updated in a couple of years, so it's up to you to go through and copy in fixes from other people. Applying those two fixes has everything working fine for me with a Heroku app/AWS&Ubuntu Wordpress setup.
Heroku will cut the request after a certain amount of time which would cause the behavior that you're seeing.
You basically have to pull the page from the wordpress blog and reserve it via Rack in the time for one request - think that could be the problem?

How to install latest official refinerycms-calendar 2.0.2 in RefineryCMS 2.1.1

I have been eating my nails the whole weekend to figure out the right combination of modifications to the official refinerycms-calendar in order to make it work with RefineryCMS 2.1.1.
Here are my conclusions and efforts, hoping that someone will drive me to the right direction:
Adding just gem 'refinerycms-calendar', '~>2.0.0'
as suggested in the github page is not working out of the box. You need to correct the dependencies on the .gemspec file. There are many forks out there created only for this correction.
So, I forked the refinery/refinerycms-calendar project, corrected the dependencies and used my fork in the Gemfile.
Backend (BE) works fine: Created an event, went back to FrontEnd (FE), got a "This page is NOT live for viewing"
This frontend (FE) inconcistency is corrected to the BE > Pages > Venues page: /calendar/venues is not an existing route and needs to be corrected to /calendar/events. The seeds.rb needs to be corrected for a permanent solution.
Go back to FE, now the /calendar/events is blank! I only get the title of the Page as defined on the relative Pages page.
A look on the rails server log reveals that there is a :find_page error resulting form the fact that the refinerycms-events.css under the engine's public/stylesheets folder is neither picked up nor referenced correctly inside show.hrml.erb and index.html.erb files. I copied the refinerycms-events.css under vendor/stylesheets and changed the reference to refinerycms-events.css accordingly.
Refreshed FE but still there is a blank page both when getting /calendar/events and /calendar/events/#{event}
NOTE: If I "rake routes" I can see that the routes for the FE portion are repeated 3 times. I am not quite sure for this behavior, but when I substituted "Refinery::Core::Engine.routes.append do".gsub("append","draw"), I could only see them once.
I have tried many forks around and all of those seem to demonstrate the same behavior.
Can anybody please let me know:
a. If you finally managed to have this (official refinery release) engine fully functional in your projects and if yes which branch was used and with which exact Refinerycms and refinerycms-calendar version combination.
b. If used used a fork rather than the official refinerycms-calendar release, then which fork/branch is that.
I hope someone to have that nailed down.
Best regards,
Petros
Well, seems that changing :body_content_left and :body_content_right with :body and :side_body respectively inside the Engine's show and index views, solves the issue of the /calendar/events and /calendar/events/:event FE pages being blank.
I am still unsure why this is causing such an issue and it is kind of weird nobody to have reported it until now.

Redmine 404 on some pages

I have installed Redmine on a shared Bluehost account and at first sight it seems to be working.
I followed both of these tutorials: https://my.bluehost.com/cgi/help/redmine and http://www.redmine.org/projects/redmine/wiki/RedmineInstall
But just as i started navigating around i noticed that there seem to be a routing problem because some of the pages are returning a 404 error code for a reason i don't understand yet.
The error log shows no information regarding this problem.
The url is on redmine.example.com , the user/pass are still admin/admin.
I have identified that any URL regarding a project is failing, for example:
http://redmine.example.com/projects/new
http://redmine.example.com/projects/21
http://redmine.example.com/projects/21/issues
(Currently i have reset the DB for privacy concerns)
In order to prove my theory that it was regarding the projects issue, i went into the projects controller file found in app/controllers/projects_controller.rb and tried to put some abort("Foo") here and there but i couldn't see my message with any of the links that are not working so i thought maybe the problem is not there and is probably in the routing process. So i checked the config/routes.rb file and comparing it with my local version they seem identical
I am not sure what to try next as i am not a Ruby developer. Let me know what kind of info you need in order to help debug this problem.
Eventually i got it working by using FastCGI.
In order to do that, i simply created a .htaccess file and a dispatcher.fcgi as shown in the answer here : Redmine 2 on Hostmonster apache fcgi: Rails application failed to start properly
Don't forget to SetEnv GEM_PATH to your ruby gems path in your .htaccess file and it should work after restarting (pkill dispatcher.fcgi)

How can I prevent cache/cookies from affecting the path of ckeditor javascript files in a production rails app?

I have a built a rails app in which I am using the ckeditor 3.5.1 together with the ckeditor gem.
When running in development, everything works fine. But when I run in production, I get errors.Sometimes, the text_area with the ckeditor does not show up. But when I clear my cache and cookies, everything works fine. Then after a while, the error comes up again. The error comes up more often than not.
Closer investigation reveals that when the error occurs, some files like staging.domain.com/javascripts/ckeditor/config.js are instead being requested from staging.domain.com/posts/config.js which is naturally non-existent
(posts is from my Post model)
How can the cache/cookies affect which path the files are served from?
Does anyone know what else might be wrong and how I can fix it?
P.S. I am using Phusion passenger in production.
It would seem the problem was being cased by mod_pagespeed which was activated. By disabling it, everything came back to normal.
I am curious though, about how this was happening.

Resources