Reputation: 8597
Trying to generate a sitemap and uploading it to my current existing bucket in Amazon's S3, however, I'm getting
Excon::Errors::Forbidden: Expected(200) <=> Actual(403 Forbidden)
This is my sitemap.rb
file
SitemapGenerator::Sitemap.default_host = "http://www.example.com"
SitemapGenerator::Sitemap.public_path = 'tmp/sitemaps/'
SitemapGenerator::Sitemap.sitemaps_host = "http://s3.amazonaws.com/#{ENV['S3_BUCKET_NAME']}/"
SitemapGenerator::Sitemap.create do
add about_path
add landing_index_path
add new_user_session_path, priority: 0.0
Trip.find_each do |trip|
add trip_path(trip.slug), lastmod: trip.updated_at
end
end
I have this in my s3.rb
file
CarrierWave.configure do |config|
config.storage = :fog
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => Rails::AWS.config['access_key_id'],
:aws_secret_access_key => Rails::AWS.config['secret_access_key'],
:region => 'us-east-1'
}
config.fog_directory = Rails::AWS.config['bucket_name']
end
Would someone be able to know what the issue is with this?
Upvotes: 1
Views: 1120
Reputation: 143
I was experiencing a similar error:
In '/app/tmp/':
rake aborted!
ArgumentError: is not a recognized provider
Going off the help of renatolond's answer above, this is the configuration that worked for me. The key is to make sure that all of your variables, such as "fog_region:" actually match up to valid values. Do not blindly copy + paste configuration credentials.
SitemapGenerator::Sitemap.default_host = "https://yourwebsitename.com"
SitemapGenerator::Sitemap.public_path = 'tmp/'
SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new(
fog_provider: 'AWS',
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
fog_directory: ENV['S3_BUCKET'],
fog_region: ENV['AWS_REGION'])
SitemapGenerator::Sitemap.sitemaps_host = "http://{ENV['S3_BUCKET']}.s3.amazonaws.com/"
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'
Upvotes: 1
Reputation: 106
My working config (which I use in heroku) is a little different than yours, here is what I have:
SitemapGenerator::Sitemap.default_host = 'http://example.com'
SitemapGenerator::Sitemap.public_path = 'tmp/'
SitemapGenerator::Sitemap.adapter = SitemapGenerator::S3Adapter.new(fog_provider: 'AWS', fog_directory: 'sitemap-bucket')
SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/"
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'
I don't use a S3.rb, instead, I set the following environment variables:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
FOG_DIRECTORY
FOG_REGION
I used the tutorial in here: https://github.com/kjvarga/sitemap_generator/wiki/Generate-Sitemaps-on-read-only-filesystems-like-Heroku
I hope it helps!
Upvotes: 1