Not able to fetch active_storage images

1. Caddy version (caddy version): v2.4.1

2. How I run Caddy:

As ubuntu services

a. System environment:

Ubuntu 18

b. Command:

 sudo service caddy restart

d. My complete Caddyfile or JSON config:

(headers) {
  header {
    Access-Control-Allow-Credentials true
    Access-Control-Allow-Origin *
    Access-Control-Allow-Headers *
    Access-Control-Allow-Methods *
    Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
    X-Content-Type-Options nosniff
    Content-Security-Policy upgrade-insecure-requests
    Referrer-Policy no-referrer-when-downgrade
    Cache-Control "public, max-age=3600, must-revalidate"
    Feature-Policy "geolocation 'none'; camera 'none'; microphone 'none'"
} {
  root * /home/azureuser/apps/example/current/public
  encode zstd gzip
  import headers
  @assets {
    path /assets/*
  reverse_proxy unix//home/azureuser/apps/example/shared/tmp/sockets/example-puma.sock

3. The problem I’m having:

When the browsers attempts to fetch an image it fails to load.
Example request URL :

Please upgrade to v2.4.3!

You defined this matcher, but you’re not using it anywhere :thinking:

You have both file_server and reverse_proxy defined, but you’re not using a matcher to tell Caddy when to use which, so Caddy will run them in this predetermined order

Meaning that reverse_proxy will always be run, ignoring file_server. Make sure to use handle blocks with matchers to tell Caddy when to do what.

I don’t know what your intent is here, because you omitted multiple sections of the help topic template. Please properly fill it out, because I can’t help without understanding what you’re trying to do.

I’m not sure what you are suggesting outside of upgrading. I did see your response here, so I made changes. This is what I currently have but still not working. {
  root * /home/azureuser/apps/exmaple/current/public
  encode zstd gzip
  import headers
  tls engineering@example.come
  @notStatic {
      not file
  reverse_proxy @notStatic unix//home/azureuser/apps/example/shared/tmp/sockets/example-puma.sock

What I’m saying is that you haven’t actually explained what you need to have work, so I can’t really suggest anything specific. Please explain what you’re trying to do. What requests do you expect to be handled in which way?

“not working” is not specific enough. How is it not working? What behaviour are you seeing, and what do you expect to happen? I can’t help if you don’t explain.

On the Caddy host, run:

stat /home/azureuser/apps/exmaple/current/public/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBamdCIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--4d05aa0b2fcd59a4e938738a94ce4e3b34bb406b/1610143094399.jpeg

Then run:

curl -IL --unix-socket /home/azureuser/apps/example/shared/tmp/sockets/example-puma.sock

And tell us what you get.

This topic was automatically closed after 30 days. New replies are no longer allowed.