Nginx & Unicorn on Red Hat - 403 errors on system reboot, restarting service fixes 403 errors

171 views Asked by At

I'm a little bit of a RHEL novice, but an experienced Rails developer. I tend to deploy apps on Ubuntu servers or through something like Heroku. Recently, an organization I provide an application for had their servers undergo routine maintenance to upgrade some of the core libraries. It, in turn, borked my entire Ruby install, and some of the init.d scripts no longer worked as expected. My application environment is:

  • Ruby 2.1.5 (was 2.0.0, just upgraded)
  • Rails 3.2.14
  • God for managing Unicorn and DelayedJob
  • Nginx as a proxy for Unicorn

All of a sudden, we were getting the dreaded 403 errors, even before updating Ruby. Upgraded Ruby to 2.1.5, and worked some magic fixing all the other issues. Everything works great!

Until I reboot.

When I reboot, all the services run properly. Nginx, God (which launches Unicorn and DelayedJob), etc... all fine. Except I get the 403 errors.

If I log into the server and type sudo service nginx restart, then the 403 errors go away completely, and everything works as expected.

I don't want to have to log in every single the server gets rebooted just to restart the process. That seems really unnecessary. Anyone have any ideas of what it could be?

If you need me to provide any files, just let me know - I'll amend them here.


Edit: This has been resolved. See my answer below.

1

There are 1 answers

0
Doug Clark On BEST ANSWER

I found out the problem was due to an upgrade to Red Hat Enterprise 6.6 from 6.0, which causes a stricter security policy enforced by SELinux. It was strange to me, as another identical server had the exact same setup, but wasn't loading Nginx at all except to throw 403 errors all over the place.

I also was unaware that the OS was upgraded.

For fixing this solution, visit: http://nginx.com/blog/nginx-se-linux-changes-upgrading-rhel-6-6/