We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    This is weird... MODx generates a Wayfinder menu to list links to a series of static resources -- no problem: the links are generated correctly as expected.

    However, if I try to click those links (or if I edit the Static Resource’s page and click "View"), I get an NGINX 404 message. If I type in the URL directly to the targeted PDF file, it DOES download as expected. It’s only when MODx acts as the intermediary that the request 404s. So I’m not sure where the problem lies... is it with how MODx makes the handoff? Or is it something in my NGINX configuration?

    I’m not even sure of a good way to test this, but it was working previously, so my suspicions lie with MODx 2.1.3 at this point.
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      I should add that a simple test php file to stream a PDF does work (so the handoff between Apache running PHP and NGINX serving the static PDF file seems to be working):

      <?php
      $source_file = '/home/user/public_html/path/to/my.pdf';
      $filename = 'yourfilename.pdf';
      header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Cache-Control: public"); 
      header("Content-Description: File Transfer"); 
      header("Content-Type: application/pdf"); 
      header("Content-Disposition: attachment; filename=$filename");
      header("Content-Transfer-Encoding: binary");
      
      ob_clean();
      flush();
      readfile($source_file);
      
      ?>



      I should also mention that the MODx resource fails regardless of whether or not it’s inline or an attachment.

      Also, there are no relevant errors in the PHP error log, Apache log, or NGINX log.
        • 15726 MODX Staff
        • 22 Posts
        Everett: It’s likely a problem with rewrites if the links are 404’ing - if you like, you can PM me your server details so I can login and look at your NGINX config. All of modx.com is running on NGINX presently, and we use Wayfinder for our menus, and have no problems with it.

        - Kevin
          Kevin Marvin :: MODX, LLC
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          Updating my NGINX to omit PDFs causes this to work (so requests for PDFs are handled by Apache). Not sure if that narrows down the cause any.