Hint: Nginx and try_files.

Discussion in '[bd] API' started by ColinD, Nov 4, 2013.

  1. ColinD

    ColinD New Member

    Nginx and php-fpm are a popular option and increasingly so. If you have followed setup guides you should've seen some warnings around passing .php to your upstream tcp/socket without question.

    The popularised fix is to do a try_files, this also gets you friendly url support.

    Code:
    try_files $uri $uri/ /index.php$is_args$args
    However if you use this alone, your api will not work. /api will respond, but anything else will fail.

    I have added a separate location definition as I want to control some aspects of api access, ssl, rate, ip [not shown] etc.

    Code:
    location /api {
      try_files $uri $uri/ /api/index.php$is_args$args;
    }
    Hopefully this will help.
     
  2. xfrocks

    xfrocks XenForo rocks!
    Staff Member

    Very useful, thank you :)

    Likewise, if the site is running Apache, the .htaccess file from root should be copied into /api ;)
     
Loading...