railsでs3に画像をアップロードできるようにしたいのですが、webサーバー(nginx)の404エラーがでます。
何か設定がおかしいでしょうか?わかる方いらっしゃいませんか?
config/initializers/carrierwave.rb
ruby
1require 'carrierwave/storage/abstract' 2require 'carrierwave/storage/file' 3require 'carrierwave/storage/fog' 4 5CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:].\-+]/ 6 7CarrierWave.configure do |config| 8 if Rails.env.production? 9 config.storage = :fog 10 config.fog_provider = 'fog/aws' 11 config.fog_directory = 'バケット名' 12 config.asset_host = 'https://s3-ap-northeast-1.amazonaws.com/バケット名' 13 config.fog_credentials = { 14 provider: 'AWS', 15 aws_access_key_id: 'アクセスキー', 16 aws_secret_access_key: 'シークレットアクセスキー', 17 region: 'ap-northeast-1' 18 } 19 else 20 config.storage :file 21 config.enable_processing = false if Rails.env.test? 22 end 23end
config/storage.yml
yml
1test: 2 service: Disk 3 root: <%= Rails.root.join("tmp/storage") %> 4local: 5 service: Disk 6 root: <%= Rails.root.join("storage") %> 7amazon: 8 service: S3 9 access_key_id: アクセスキー 10 secret_access_key: シークレットアクセスキー 11 region: ap-northeast-1 12 bucket: バケット名
Gemfile
gem "carrierwave" gem "fog-aws" gem "aws-sdk-s3"
/var/log/nginx/error.log
※nginxのログ
log
12020/03/06 23:46:18 [crit] 4558#0: *391 open() "/var/lib/nginx/tmp/client_body/0000000031" failed (13: Permission denied), client: xxx.xxx.xxx.xxx, server: app.com, request: "POST /action HTTP/1.1", host: "ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com", referrer: "http://ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com/action" 22020/03/06 23:46:18 [error] 4558#0: *391 open() "/home/app_user/app/public/50x.html" failed (2: No such file or directory), client: xxx.xxx.xxx.xxx, server: app.com, request: "POST /action HTTP/1.1", host: "ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com", referrer: "http://ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com/action"
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。