Platoniq / decidim-install

A step-by-step guide to install Decidim on a production site
https://platoniq.github.io/decidim-install/
GNU Affero General Public License v3.0
54 stars 35 forks source link

Server error when trying to upload file to S3 #26

Closed FPoezevara closed 5 years ago

FPoezevara commented 5 years ago

Hi,

I deployed decidim on AWS following this guide : https://github.com/Platoniq/decidim-install/blob/master/decidim-aws.md

Everything seems to be working fine, except for the file upload (I'm trying to use s3). When I try to upload a logo in the appearance settings page, I have this error message:

There was a problem with our server Please try again later.

I tried to create a new bucket on s3, with new policy and new user, but it's exactly the same behavior. I tried both EU (Ireland) and EU (Paris) (as my EC2 is on eu-west-3), but neither of these works.

Is there a way to know what is dysfunctioning, like a log or something please? Do you know what could be the cause of this issue?

Thanks, Best regards

microstudi commented 5 years ago

Maybe you have restricted too much your permissions in the bucket. It should show as "Objects may be public" in the list of buckets in S3.

Like this: imatge

FPoezevara commented 5 years ago

Thank you for your answer, indeed everything was at "True" by default. Anyway, the issue is still happening (same message). Do I need to update anything in my configuration after changing the s3 settings? Do you know if I should take my eu-west-3 s3 bucket or my eu-west-1, as I am using EC2 eu-west-3 for my app? Thanks!

microstudi commented 5 years ago

It may be something missconfigurated. It would help if you post here your config/initializer/carrierwave.rb file. Also the policy used in th bucket. I don't think the region matters as long as the permissions are right.

FPoezevara commented 5 years ago

Here is the content of config/initialiser/carrierwave.rb :

`if Rails.application.secrets.aws_access_key_id.present? require "carrierwave/storage/fog"

CarrierWave.configure do |config| config.storage = :fog config.fog_provider = 'fog/aws' config.fog_credentials = { provider: 'AWS', aws_access_key_id: Rails.application.secrets.aws_access_key_id, aws_secret_access_key: Rails.application.secrets.aws_secret_access_key, region: 'eu-west-3', host: 's3.eu-west-3.amazonaws.com',

endpoint: 'https://s3.example.com:8080'

}
config.fog_directory  = ENV.fetch("AWS_BUCKET_NAME", 'my-decidim-2')
# config.fog_public     = false
config.fog_attributes = {
  'Cache-Control' => "max-age=#{365.day.to_i}",
  'X-Content-Type-Options' => "nosniff"
}

end end` (my-decidim-2 being the bucket's name).

The bucket policy is empty : image

Thanks !

FPoezevara commented 5 years ago

Update: it does work now, without modifying anything. I just needed to wait a little bit (I don't know how long, I just get back to my app a few days later). Thank you!

microstudi commented 5 years ago

Glad to hear it. Sorry I couldn't check that before, I've been too busy.