Caught race condition abuser - ruby-on-rails

The images we uploaded to the site are not showing . When we see the apache error_log file we found the following error,
Caught race condition abuser. attacker: 0, victim: 99 open file owner: 99, open file: /var/www/site_prod/current/public/system/banners/8/original/nGGEDx_Ben_Renick_Banner_-_10K_.png, referer: http://prod.site.com/en/get-help/get-help-shipping-standards
What could be the reason. We have a rails 4 application with capistrano deployment hosted in centos .
All file/folder permissions have been assigned.

I can see you have enabled Symlink Race Condition Protection on your server and installed Apache patch on your server and due to that you are getting this issues, You will have to check your file and folder ownership.
https://documentation.cpanel.net/display/EA/Symlink+Race+Condition+Protection

Related

Rails production: Directory index forbidden by Options directive

I'm working on deploying my rails app using apache and passenger on a virtual server that I'm managing via Virtualmin. All of this is being hosted on an Ubuntu 12.04 VPS.
Anyway, I'm getting the following error.
Forbidden
You don't have permission to access / on this server.
At first, when this occurred, I was getting the error:
Premature end of script headers
in my virtual host error log and a key error in my apache error log. Both of these went away though once I updated my config/secrets.yml file. The 403 error, however has remained. Additionally, the virtual server error log had the error:
Directory index forbidden by Options directive
Additionally I've made sure that my public_html directory (and all of is subdirectories) is the right user for apache. I've checked the production error log, and apache error log and haven't seen anything come out when I load the page.
Any ideas as to what I should try?
Many thanks in advance

Apache2 Won't Reload: Looking for a File I Intentionally Deleted

Okay, so I'm following a guide to get set up with a Rails production server, and it says the following in the Apache2 setup:
We have to create a virtual host by creating a file in the "/etc/apache2/sites-available" directory (we will name it "site" - the file won't have any extension but it will be a text file).
$ sudo nano /etc/apache2/sites-available/site (this will create the file named "site" - can be any name - AND open it for editing)
Copy and paste this into that file (compare also with what the notes after installing mod_rails tells you):
VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot /home/user/public_html/site/public
/VirtualHost>
When I was first testing the waters with Apache I did as it said, making a fake scaffolded Rails app called "site". Now I want to use my real site, which we'll call "realthing." So I did
# sudo mv /etc/apache2/sites-available/site /etc/apache2/sites-available/realthing
And put my new settings into the renamed file. So far so good.
Then I went to restart Apache. Problems begin.
# sudo a2ensite realthing
Enabling site realthing.
To activate the new configuration, you need to run:
service apache2 reload
Okay, I can do that.
# sudo service apache2 reload
apache2: Syntax error on line 230 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/site: No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
Fail indeed. Nothing I can seem to do can get this thing to restart without flipping out about the missing "site" file. I check line 230 of /etch/apache2/apache2.conf for any specific references. Nope:
Include sites-enabled/
It's a generic reference to the folder containing "site". But no mention of "site".
So what's up? How do I get Apache to forget about the fake site "site" and move on to the real thing "realthing"? It's driving me insane that even a superuser reload is failing because Apache can't find a file that as far as I can tell it has no reason to expect to find.
Even a hard
sudo service apache2 stop
and
sudo service apache2 start
doesn't work. Again with the
* Starting web server apache2
apache2: Syntax error on line 230 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/sites-enabled/site: No such file or directory
Action 'start' failed.
This is driving me bonkers. Any ideas?
The Apache error log may have more information.
You probably still have a symlink from sites-enabled/site to the now missing sites-available/site

Ruby on Rails Setup: Unable to access log file

I'm setting up Ruby on Rails for the first time; on my server, I've created and loaded the default rails app. I can view the default page ("Welcome aboard! You are riding Rails"), but when I go to click on the link to "View Application Environment", it generates a 500 error.
(You can view it here.)
I'd like to know more about the error, but, the log file ("log/production.log") is empty. Looking at my Apache log I find:
Rails Error: Unable to access log file. Please ensure that
/var/www/rails/myapp/log/production.log exists and is chmod 0666. The
log level has been raised to WARN and the output directed to STDERR
until the problem is fixed.
So, I actually want to get my Ruby on Rails error logging working.
I know this problem has been posted a few times before, but I tried everything I could find, so here's what I have tried:
Created the "log/production.log" file, set the owner to www-data, set chmod 0666.
Set the owner of the "log" folder to www-data, set chmod 0666.
Double-checked my production environment settings such that config.log_level = :info is set.
Checked that Apache is using the www-data user ("etc/apache2/envvars"):
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
"etc/apache2/mods-available/passenger.conf" has a default user set for Passenger:
<IfModule mod_passenger.c>
PassengerRoot /usr
PassengerRuby /usr/bin/ruby
PassengerDefaultUser www-data
</IfModule>
The owner of "config.ru" and "configs/environment.rb" is www-data
My virtual host has been set accordingly:
DocumentRoot /var/www/rails/myapp/public
RackBaseURI /
RackEnv production
PassengerMaxPoolSize 4
Already read and attempted all the fixes suggested in these places:
Rails: Unable to access log file
Can't access log files in production
http://railsforum.com/viewtopic.php?id=36168
Why am I getting Permission denied error in deployment on files generated by capistrano?
http://bradhe.wordpress.com/2011/06/26/a-sneaky-rails-3-bug-in-logging/
(That's all I can remember trying right now...)
Some environment settings of mine:
Ubuntu 11.10 running on Amazon EC2
Apache 2.2.20
RVM 1.10.2
Ruby 1.9.3p0
Rails 3.1.3
This issue is resolved now, though the the cause of the problem itself isn't entirely clear.
I had some weird configuration issues with Apache & Passenger (a.k.a. ModRails). Two modules existed: one that appeared to come packaged with Apache(?) and one I obtained via passenger-install-apache2-module. When I pointed to the pre-installed one, I had this logging issue. When I pointed to the one deployed by passenger-install-apache2-module, I had a completely different issue where Passenger would crash with a segfault (see my post on ServerFault here.)
In the end, I completely wiped my server and performed a clean install of everything from the base Ubuntu AMI (running on Amazon EC2 made this easy enough.) Upon reinstalling, I ran passenger-install-apache2-module and configured Apache to load the module deployed by it. This time, the module didn't crash, but the log error appeared. I set chmod 755 on the root of my Rails application, made sure the production.log existed and that it had at least chmod 0666 privileges. And voila, problem gone.
TL;DR Did a fresh install, made sure I was using the latest Passenger module, and my file permissions were set properly.

Is it a bad idea to put apache conf files in my rails app's config directory?

I have a dedicated CentOS server. I manage all my users, apps, and virtual hosts manually. I'm using Apache 2.2.3 and Passenger 3.0.7 to serve my apps. I have a typical httpd.conf file in /etc/httpd/conf/ that includes all *.conf files in my /etc/httpd/conf/vhosts/ directory. Normally for each app I create a new sample-domain.com.conf file in the vhosts directory.
However, I have a particular app that needs frequent apache configuration changes, and I'd like it to be more a part of my app and its version control. So I've moved my apache configuration file into the apps config directory. I added a script to my Capistrano deploy.rb that sets the permissions on the apache conf file in the app to 755. I added an include line in my vhosts that includes the symlinked current version of the apache conf file from the app.
Which brings me to my simple question: is this safe or a bad idea?
For frequent config changes in Apache, consider using a .htaccess file instead. Changing .conf files requires bouncing/hupping the server, and if a .conf file has an error, that'll kill the whole server and take down all sites. A .htaccess error will take down just the one site/directory where the file is.

Ruby error on non-ruby site

A friends of mine have a shared hosting with many sites hosted. There is ruby on rails, php, xslt/xml sites using mysql or postgress. Today one of the xslt sites displays this error:
Passenger error #2
An error occurred while trying to access '..../config/environment.rb': Cannot stat '..../config/environment.rb': Permission denied (13)
Apache doesn't have read permissions to that file. Please fix the relevant file permissions.
This is, as I Know, a ruby error (*.rb), but there is no ruby app here! And no any config/ catalogue.
The error log says:
(13)Permission denied: /home/..../.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
The .htaccess file in the htdocs directory is present and have 777 permission for now.
I haven't any idea what does it mean.
I experienced the same problem, Passenger error #2, suddenly and without correlation to any configuration change on my part. I did not add Ruby. I contacted host monster tech support, their level 2 support was baffled.
Confirming that Jaap Haagmans' solution; overriding PassengerEnabled with no from the .htaccess located in public_html works. Thank you kindly Mr.Haagmans.
I think the configuration of either your apache or nginx state that passenger is enabled. Check for a "passenger_enabled on" on nginx or "PassengerEnabled on" on apache in your webserver configuration file. Then disable it on top level or in the virtual host that runs a php website.
You could instead try to put "PassengerEnabled on" in a .htaccess file in the public_html folder (or equivalent, e.g. httpdocs). Also, make sure the .htaccess file is readable (e.g. 644 permissions in Linux), as that's what the error in your error log is saying.
Looks like there are some leaks in the web host's configuration. Passenger (which is like a mod_rails apache extension) is looking to load a particular Rails app's configuration, presumably not yours. If you're doing something important (like an e-commerce site) I'd run far away from the hosting company. Otherwise you'll have to get this resolved through them.

Resources