Wild guess:
When a request is made against a picture in /storage/, it triggers the
location not found * rule.
The rewritten request does never hit the location "/storage/*" rule
because it now requests /index.php$something instead of any object
within /storage.
Try placing a matching /storage rule before the location not found *
rule and see what happens. This is where the rule belongs anyway,
because specific rules ought to be placed before more generic rules.
Am Jam wrote:
Hi Everyone,
I am trying to install and run pixelfed (think of it as a self-hosted
instagram alternative) on OpenBSD 7.5, but I am having a problem with my
/etc/httpd.conf. Unfortunately, pixelfed's installation instructions
only provide an nginx example. For those of you familiar with nextcloud,
pixelfed is similar -- it's essentially a large php application that one
can unpack under /var/www/.
I have chosen to "install" (i.e. unpack) pixelfed into
/var/www/pixelfed. After chown -R www:www'ing the entire directory,
everything "works" except for one critical part -- none of the images
load, which, for an instagram alternative, is an issue :)
What works is everything else -- I can browse around, create a user,
login, adjust my settings, and post images (which ultimately don't show
up). Everything works except displaying images. This expands to more
than just uploaded photos -- for example, the main page's header image
won't load.
I believe I have pinpointed the issue, but I struggle to translate that
into my /etc/httpd.conf.
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).
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.
My /etc/httpd.conf is below, and you can see that I have tried to re-set
the root directory whenever someone navigates to "/storage/*", but it
doesn't work. Does anyone know what I'm doing wrong?
P.S. -
Running the following makes all images work, but I hesitate to use this
as a long-term solution:
- cd /var/www/pixlfed/public
- cp -a /var/www/pixelfed/storage /var/www/pixelfed/public/storage_blah
- ln -s /var/www/pixelfed/public/storage_blah/app/public storage
Many Thanks.
/etc/httpd.conf:
server "www.domain.com <http://www.domain.com>" {
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 "/storage/*" {
root "/pixelfed/storage/app/public"
fastcgi socket "/run/php-fpm.sock"
}
location "/*.php" {
fastcgi socket "/run/php-fpm.sock"
}
}