Tuesday, May 28, 2024

Re: httpd & pixelfed

Rubén, Crystal, & Stuart--

Your responses helped me figure it out. 
In particular, Stuart, you were right. My problem was having an absolute symlink from /var/www/pixelfed/public/storage -> /var/www/pixelfed/storage/app/public.
Making this a relative symlink (i.e., cd /var/www/pixelfed/public && ln -s ../storage/app/public storage) did the trick.

For posterity's sake, my working /etc/httpd.conf is below:

        listen on * tls port 443

        # acme-challenge TLS location
        location "/.well-known/acme-challenge/*" {
                root "/acme"
                request strip 2
        }

        # enable HTTP Strict Transport Security
        hsts {
                preload
                subdomains
                max-age 15768000
        }

        tls {
                certificate "/etc/ssl/domain.com.fullchain.pem"
                key "/etc/ssl/private/domain.com.key"
        }

        # set logs
        log {
                access "pixelfed-access.log"
                error "pixelfed-error.log"
        }

        # set max upload size to 1G (in bytes)
        connection max request body 1048576000
        connection max requests 1000
        connection request timeout 3600
        connection timeout 3600

        root "/pixelfed/public"
        directory index "index.php"

        # works roughly like the `try_files` line of an nginx config
        location not found "*" {
                request rewrite "/index.php?$QUERY_STRING"
                fastcgi socket "/run/php-fpm.sock"
        }      

        location "/*.php" {
                fastcgi socket "/run/php-fpm.sock"
        }
 }

On Tue, May 28, 2024 at 2:13 AM Stuart Henderson <stu.lists@spacehopper.org> wrote:
On 2024-05-27, Am Jam <intdfdx@gmail.com> wrote:
>
> Most of what makes pixelfed work is located in /var/www/pixelfed/public,
> and hence pixelfed requires that the root directory be
> /var/www/pixelfed/public.
> So in /etc/httpd.conf I have the following lines:
> -   root "/pixelfed/public"
> -   directory index "index.php"
>
> However, for some bizarre reason, all the images are stored in
> /var/www/pixelfed/storage (note: *not* /var/www/pixelfed/public/storage).

Probably not bizarre. I expect they arrange things so that everything
under /var/www/pixelfed/public can be read-only (or at least not writable
by the user running the web server).

> And part of the pixelfed installation process includes creating the
> following symlink in /var/www/pixelfed:
> -   lrwxr-xr-x  1 root  www    37B May 27 12:15 storage@ ->
> /var/www/pixelfed/storage/app/public/
>
> That, unfortunately, is "outside" of the root directory specified in
> /etc/httpd.conf.

httpd is in a chroot jail so the absolute symlink won't work.

Either use a relative symlink for the above link, or set things up so
that /var/www still works inside the chroot -

mkdir /var/www/var; ln -s .. /var/www/var/www


No comments:

Post a Comment