Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
Tekphotos
Topic Author
Posts: 6
Joined: 03 Jun 2012, 13:53

Thumbnails not displaying nginx

20 Jul 2018, 15:38

Hi Karl,
Sorry to post another thumbnail thread but I've tried all the troubleshooting found on the forums but I can't seem to get thumbnail generation to work when I'm using nginx.  I have the config file set up with the rewrite rules from your github/gist and the diagnostics page says everything is okay but thumbnails result in a 404 error.

I'm not seeing any php errors or nginx errors in the logs so I'm having some trouble tracking down where the rewrite is failing or if it's some other setting that is preventing the thumbnail generation.  It's a fresh install with minimal content and I'm trying to test it out on a centminmod install running Centos 7.  If you want to pm me a public key I can give you access to the server if needed.

Site: beta.tekphotos.org
ImageImageImage
------------------
http://www.tekphotos.org
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Thumbnails not displaying nginx

20 Jul 2018, 23:09

I wish I was a web server expert, but unfortunately I am not, especially not Nginx and if this is a custom server setup, I wouldn't know where to start looking for any issue that prevents the rule from working. I am guessing the issue could be a missing standard configuration, or some rule interfering.

There are THREE crucial rules in the NGINX, and I can see #1 and #3 are already working:
Code
  location / {
    if (!-e $request_filename){

      # Rewrite any calls to html|json|xml|atom|rss if a folder matching * exists
      rewrite (.+)\.(html|json|xml|atom|rss)$ $1/ last;

      # Rewrite any calls to /render to the X3 image resizer
      rewrite ^/render/. /app/parsers/slir/ last;

      # Rewrite routes to X3 application index.php if they are non-existent files/dirs
      rewrite ^(.*)$ /index.php?$1 last;
    }
  }
So why isn't "rewrite ^/render/. /app/parsers/slir/ last;" working on your server? I really don't know, but something is interfering with path, or maybe "index.php" is not setup as default. Or maybe it's something to do with your sub.domain setup.
 
User avatar
Tekphotos
Topic Author
Posts: 6
Joined: 03 Jun 2012, 13:53

Re: Thumbnails not displaying nginx

22 Jul 2018, 23:53

Thank you for at least looking at it, I'm trying to narrow it down but like you said I can't seem to see why the render rewrite rule isn't working as intended.  I was hoping you had coded in some other troubleshooting tools but it looks like I'll have to keep digging around.
------------------
http://www.tekphotos.org
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: Thumbnails not displaying nginx

23 Jul 2018, 01:47

I did some more testing, and think I have found out the culprit at least.

Check the below URL:
https://beta.tekphotos.org/render/nothing/nothing/

You will see that the REWRITE rule is applying correctly. The above will of course return an error, because there is no image /nothing/nothing/, but it shows that the rewrite rule is correctly rewriting to /app/parsers/slir/.

Now, check URL with a file extension .jpg instead:
https://beta.tekphotos.org/render/nothing/nothing.jpg

It returns a standard nginx 404 "file not found", entirely bypassing rewrite rules.

Let's check same url with a non-existent extension .xyz:
https://beta.tekphotos.org/render/nothing/nothing.xyz

Now, you can see the rewrite rule is WORKING again.

Conclusion
Clearly you have some rule in a parent configuration somewhere to BYPASS rewrite rules if the request ends with ".jpg" (or probably any known static file type). This is not unheard of, because server may be setup to bypass rewrite rules on static file types for maximum efficiency. However, this will not work in X3 ... If done correctly, the server could be setup to bypass rewrite rules if (and only if) the requested path actually exists. In your case, your server is blindly bypassing rewrite rules just because the request ends with ".jpg".