OpenURI Open Throws 403 Forbidden - ruby

I've written code that allows users to search for specific images through the Google Image Search API and then downloads those images using Carrierwave's remote image functionality. We're getting bug reports though that certain URL's are throwing 403 Forbidden errors and we traced it back to
Kernel.open(url)
Scanning existing issues got me to "'open_http': 403 Forbidden (OpenURI::HTTPError) for the string “Steve_Jobs” but not for any other string" which suggests that the problem is due to the missing User-Agent and so we added this to our call.
Kernel.open(url, 'User-Agent' => "Ruby/#{RUBY_VERSION}")
This resolved the issue in our dev environment but it had no effect at all in our production environment. This is the most frustrating part. My production environment (running on AWS EC2 Ubuntu 12.04) fails everytime and for far more URL's than my dev environment (OSX 9.5). Both environments are running ruby 2.0.0-p353 and rails 4.0.5.
We've isolated several test URL's that we can consistently re-created this problem.
Example: http://www.lowes.com/images/LCI/Planning/HowTos/ht_BuildaHomePlayground_kit.jpg
I'm running out of ideas, but it seems to be something specific to the AWS box (since it works in dev) so is it possible that AWS is using some sort of outbound filter/proxy or that Ubuntu 12.04 has a known issue with OpenURI?
Scouring the internet is starting to run out of options.
UPDATE
I have two AWS instances running, that were supposed to be identical to each other, but upon closer examination, one is running GNU/Linux 3.2.0-58-virtual and the code above works properly (thats my staging environment), and the other is running GNU/Linux 3.2.0-68-virtual and the code above fails (thats my production environment). So the issue would seem to lie in whatever changed between 58 and 68.
For now, I'm switching my production and staging environments so that the issue is resolved, though it feels like a temporary and invalid fix since the staging environment is likely to be upgraded at some point thus landing us back at square one.

Related

Template doesnot exist when running on heroku but exists when running locally

I just created my first heroku app and pushed my code through it onto heroku. While testing it however, it showed that one of the templates didnot exist when it infact does when I test it from my laptop directly on the local server. Please do guide if you have any ideas!(ps.: I am using Windows hence please do keep take that into consideration when helping out!)

Move OctoberCMS website from Ubuntu VM to a CentOS 7 VM

Our web developer picked OctoberCMS to develop our new website (his skill). Unfortunately before completion he rapidly left us due to health reasons and is no longer available. His Ubuntu environment has some problems and we need it on CentOS 7 anyway. The rest of us are OctoberCMS newbies, but want to learn it.
We built a CentOS 7 VM and installed OctoberCMS and want to move his work over.
We can not find any instructions on how to "export" the work he has done thus far and import it into our new OctoberCMS.
He is using 10 plugins and 3 he developed. (I don't know if that is relevant)
Is there an easy way to do this or at least instructions?
We have been googling, youtubing, IRC'ing for a week and still at a loss.
Any help would be most appreciated.
There really isn't anything special you need to know about moving an OctoberCMS install to a new server compared to moving over any other PHP application.
I am assuming you know how to do the basics of setting up a LAMP stack, such as setting up a virtual host for the domain you want to host the site on and setting up a MySQL database and user/password to access the database. There are of course many variants on how you could accomplish this such as using a management tool like Plesk or cPanel, or just configuring the services manually via the command line.
1) Ensure your new server is running at least roughly the same version of Apache, MySQL, and PHP.
2) Copy over the directory that contains all of the web files from the old server into the document root for your domain on the new server.
3) Do a database dump from the old server and copy it to the new server. If possible, use the same database name and username and password as the old server. This way you don't have to worry about updating the configuration of the website.
4) Pull up the site and troubleshoot any errors that come up. It is helpful if OctoberCMS debug mode is on.
Following the above method will ensure that you have the exact same setup on your new server that the old server had. This will copy over all of the plugins, data, etc.
There are of course many complexities that can come up during a switch over like this, but this should at least get you started and you can come back to StackOverflow with some more specific hurdles.
Hope that helps.

AWS Elastic Beanstalk: Launching a new Rails App

I just started using AWS elastic beanstalk to host a web app I wanted to make. However, after following the instructions twice start to finish I get the same end result. Status shows everything is fine, but I keep getting this message:
The status is fine:
And I can view my app on localhost it just doesn't seem to work on beanstalk...
When I first ran eb init these are the settings I chose:
1) US East (Virginia)
2) 64bit Amazon Linux running Ruby 1.9.3
3) No DB instance for now.
Has anyone experienced this problem? What could possibly causing my app to not want to work on beanstalk?
After waiting a couple of hours it finally loaded my index page. I guess it just take a while for my pushed changes to show up.

Production issue with carrierwave and S3

I was wondering if someone could help me, I've recently added the ability to upload images in my rails application using carrierwave, fog, and S3 for storage.
The application is running on Ruby-1.9.3-p194 and Rails 3.2.11 and in development the application is working fine I can upload images all day long, however in production I seem to be getting an intermittent "Excon::Errors::SocketError: Broken pipe (Errno::EPIPE)" and I say intermittent because I've managed to successfully upload a couple of images in production but I get this error more often.
I've spent some time looking into it but at present I am at a loss as to what is causing this.
So after doing some further digging it appears that it may have been because the region was incorrectly set in my config, I've run a test and all seems to be working correctly again.

Symfony2 deployment via ftp

I tried to deploy my project with capifony, becouse I found here an answer, that with capifony deployment is easy. Well I don't think it is, so my question is:
How can I deploy my project via ftp, I put all my files on the server but even if I browse to web/app.php, the only thing I get is an empty page, whatever route I write in the url. So someone please explain me how can I get this work! Thank you!
A couple of things to think of when deploying a Symfony2 project to a new server or computer (as far as I've encountered) might be:
Make sure that the server and it's PHP installation meets the Symfony2 requirements (and perhaps also the recommendations)
Check that you've somewhat followed the installation instructions (found here)
Try to clear the cache
Make sure that the web server and it's PHP process have write permissions to the cache folder
If none of these helps, try to modify the app_dev.php to temporarily allow access from your current (client) IP (instead of restraining it to localhost). Then, hopefully, you'll get a more useful and detailed error message, instead of the blank page (which often is caused by some fatal error that have occurred during the initialization of the framework and its kernel)
Update: Noticed now that you've tagged your question with 'windows', but that you don't mention which server you're trying to deploy to. I wrote the above with some *nix based server in mind, but hopefully some of it are applicable to Windows servers too (but there might be other common sources of error running under Windows that I'm not familliar with

Resources