403 Forbidden for static files

I am trying to serve static files from a folder while proxying actual requests to another application. My current Caddyfile looks like this

domain.com {
    root /var/www/domain.com
    proxy / localhost:8000 {
        transparent
        except /static/
        #the static files are at /var/www/domain.com/static/
    }
}

I’ve tried changing the permission of everything in the /var/www/domain.com folder. Currently all files within that folder belong to root:www-data, and www-data is the user running caddy.

I can see that he requests are not making it to the proxied application so they must be getting blocked by caddy. What should I be doing differently?

Can you give us the output of ls -al /var/www/domain.com/static?

Also, setting the -log stdout flag on the command line when running Caddy, and adding log stdout and errors stdout to your Caddyfile, might give some useful information when these 403s occur.

Paths that don’t begin with /static/ should be proxied.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.