jeffpiazza / derbynet

Open-source Pinewood Derby race management, built around a web server and database
MIT License
98 stars 72 forks source link

Photo.php failing with 404 errors #338

Open srozga opened 1 month ago

srozga commented 1 month ago

Hi I am taking DerbyNet 9.0 for a test drive on my Mac. I am using MAMP and running DerbyNet on nginx as I was having an impossible time starting apache. I configured the software to use two local folders for racer and car photos. I initialized the database with a fake roster. Both aforementioned folders now contain a variety of SVG files. But when I navigate to the racer checkin page, the images show up broken.

All of the photo requests result in 404s as below.

image

I tried to take photos of myself using camera and upload new car and racer photos. The new photos is uploaded. Action.php succeeds and I see a photo of myself on the filesystem. However, photo.php still results in a 404.

Any tips on how to diagnose? Thank you.

srozga commented 1 month ago

Adding some more info, I found the nginx error logs and found entries like this. Seems like nginx is not mapping the call into actually calling photo.php and mapping the URL parameters but rather it thinks photo.php is a directory... yikes. More details below. 2024/08/13 12:16:19 [error] 9768#0: *360 open() "/Library/WebServer/Documents/derbynet/photo.php/car/file/200x200/fake_27.svg/1723563570" failed (20: Not a directory), client: 127.0.0.1, server: , request: "GET /photo.php/car/file/200x200/fake_27.svg/1723563570 HTTP/1.1", host: "localhost:8888", referrer: "http://localhost:8888/photo-thumbs.php?repo=car&order=name"

Not sure why it's trying to open that path.... It uploads the files into the correct folders:

image

You can see the actual file here:

image
jeffpiazza commented 1 month ago

I'm not sure what the out-of-the-box config for nginx looks like, but it likely doesn't have provision for recognizing .php extensions when they occur in the middle of the URL, as they do for photos. That is,

http://localhost:8888/photo.php/car/file/200x200/fake_9.svg/1723563057

is supposed to pick up /Users/srozga/derbynet/photo.php as the PHP source file, and then photo.php interprets the

/car/file/200x200/fake_9.svg/1723563057

part to locate (or construct) the image file.

Here's a snippet from the config file used for nginx on Linux that might help. (Note that it still gets updated during installation, so don't expect to just paste in and have it work.)

  access_log /var/log/nginx/access.log derbynet_log;

  location /derbynet {
    index index.php;
  }  

  location ~ derbynet/.*\.php(/.*)?$ {
    client_max_body_size 16M;
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param DERBYNET_CONFIG_DIR /var/www/html/derbynet/local;
    fastcgi_param DERBYNET_DATA_DIR /var/lib/derbynet;
    # fastcgi_read_timeout value goes here, if needed.
  }

Perhaps it's worth asking what the issue was with Apache, as that doesn't usually give difficulty.

srozga commented 1 month ago

@jeffpiazza I opened another issue to track that problem here: https://github.com/jeffpiazza/derbynet/issues/339