404 Error nginx + unicorn - ruby-on-rails

I have very weird issue of 404 page not found. I already have custom 404 page but my app render its own 404 page- I guess for some request my app does not get any hit for example -
(1) http://www.mymster.com/neerajsridhar renders default ngix 404 page,but
(2) http://www.mymster.com/khanimdads renders custom 404 page
The main issue is not custom 404 page but the error which is: - For point (1) above there is record in my DB ('neerajsridhar' is username in my DB), it works fine on my local machine but not in production mode.
Few inputs which may help in fixing this
a) I have used fragment caching for above page
b) Above page had 301 permanent
c) Environment is - Rails 4, ruby 2, unicorn, nginx and pagespeed.
http://www.mymster.com/stack/once-upon-a-time-in-mexico-12061 - this page do not have any 301 permanent redirect so it should work, but does not.
Any help would be appreciated.

Related

Get error 404 page not found

My site running yesterday very well but suddenly today get "404 page not found" error. My site developed in Ruby-on-Rails and MySQL database.
Not Found
The requested URL / was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Why do I got this error? Its server issue or any code issue on server?
Can you access the /some_controller resource directly if you point your browser to it? The same holds true for your CSS files. Can you post a snippet of the HTML source that includes a the HREF's or the SRC's for your links/CSS?
Edit...
Now that I look at that rewrite rule, of course it doesn't work.
^/?$
That's only going to match a URL at /. Change it to:
RewriteRule ^(.*)$ http://127.0.0.1:12007/$1 [P,QSA,L]
And it should tick. Note that the above will proxy all requests to Rails. You should probably host your media outside of Rails' control, but that's an exercise for the reader.
Source: Ruby on Rails application only works if the address contains the port

Heroku 500 Internal Server Error on broken pages

My app is being hosted on Heroku and when I go to a broken page on my website (ie. www.example.herokuapp.com/mumbojumbo), i get a 500 Internal Server Error message.
Obviously, when I go to a broken page something will go wrong, I would just prefer it to show the Oops error page that I made that's on an Amazson s3 like Heroku suggests.
How can I fix this?
Right now, I already have a custom Error Page that set up in Heroku.

JRuby/tomcat 404 errors in rseponse to ajax GET

This problem appears specific to routing for JRuby ajax requests. My page sends an ajax GET which works fine in rails development mode. When moved to tomcat via warbler, the request is generated correctly, but tomcat responds with a 404 error.
In other words, the line in routes.rb get '/sector/method' is sufficient that http://localhost:3000/sector/method is processed by Webrick, but if I change the port to 8080 (tomcat) I get a HTTP status 404 The requested resource (/sector/method) is not available.
Apparently tomcat needs to be told it is OK to process the GET even though there is no corresponding file to be found. Right? Fixes?
Thanks.
Are you sure your request point to correct address? if application works, there is no way that GETs does not. Please try to put the request directly into your browser and check...

symfony - 500 error page customisation problem

I am ready to push a site to production (currently on staging), but I'm having a slight problem with the internal server error 500 page.
I have created a file in web/errors/error500.php and I've also got: ErrorDocument 500 errors/error500.php in my .htaccess file
The problem is, if there is a 500 error in the admin, it displays the symfony default 500 page instead of mine in the errors folder.
Does anyone have a rough idea why this is?
I've cleared symfony cache, cleared browser cache and used several browsers.
Thanks
The standard Symfony way of doing this isn't with an Apache ErrorDocument directive, but simply by putting your error page in either <project>/apps/<appname>/config/error/error.html.php or <project>/config/error/error.html.php, for per-app or general error pages respectively. See this checklist item on the very handy Symfony Deployment Cheat Sheet.
Also make sure you are not in debug mode when you test this otherwise it will still show full stack trace.

how to handle errors like 404 / 500 in rails3

Hey, I hope you can help me.
I am trying to find a way to direct the user to the default error pages 404.html and 500.html in my public folder.
So when there is a routing or nomethod error it should be directed there to.
I already tried some stuff in my application controller but it didnt work.
Many thanks!!
Rails does this for you automatically when running in production mode. When you upload your application to a live server, Rails takes care of handling those exceptions and rendering the correct error pages with the correct header status. If you're trying to see what those pages look like (for testing or something), just access them directly via http://localhost:3000/404.html
Whenever you set up your Rails application on a live server (let's use Apache as an example), you give the site root as the /public folder in your application. Then, whenever a request is made to that server address, Apache first looks in that public folder and tries to serve a static asset (this is a configurable option in [environment].rb). If it can't find the requested page, then the request is forwarded through the Ruby stack.
When in production mode, if Rails encounters an error that isn't handled (i.e begin, rescue), it throws the error the whole way up to the stack, which then tells Apache (again, in my example) to render an appropriate error.
Here are some common errors that you'll see in development mode and what they render in production mode:
ActiveRecord::RecordNotFound => 404 (page not found)
nil.method => 500 (server error) unless you turn off whiny nils
ActionController::RoutingError => 404 (page not found)
Happens automatically if run in production mode - no need that you do that manually.
Have a look at this post to redirect all requests causing a Routing Error.

Resources