On 10/17/2014 07:36 PM, "Jan B. Kolář" wrote:
> Dear all,
> I can't figure out how to set up Nginx for "rest.php" authentication to 
> work. I'm using Nginx+PHPfpm and MySQL as backend (I want use "Internal 
> authentication"). Web interface is working fine - I can log in without a 
> problem.
> But I can't use integration with Thunderbird, because "rest.php" file is 
> always returning "401 Unauthorized" without asking for username and 
> password (no login dialog appear). I can't find any help in manual.
> My Nginx config part for "rest.php" file is:
> location = /rest.php {
>        fastcgi_pass_header Authorization;
>        fastcgi_pass unix:/var/run/dl.smurv.cz-fpm.sock;
>        fastcgi_index index.php;
>        include fastcgi_params;
>    }

I just tried a stock DL 0.15 using nginx on Debian.
When installed as a subdirectory, I could get DL to work with the following:

location ^~ /dl {
      # Protect the include directories
      location ~ ^/dl(?:/|/.*/)include {
          deny all;

      index index.php index.html;
      try_files $uri $uri/ =404;
      # Enable PHP
      location ~ \.php(?:$|/) {
          include fastcgi_params;

          # Set maximum body size (should be the same as PHP's post_max_size)
          client_max_body_size 512M;

          # Setup PATH_INFO
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          try_files $fastcgi_script_name =404;
          set $path_info $fastcgi_path_info;
          fastcgi_param PATH_INFO       $path_info;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_index index.php;
          fastcgi_pass unix:/var/run/php5-fpm.sock;

Notice the order of the location directives to protect the include directories, 
and also the PHP location matching ``\.php(?:$|/)'' in order to allow PATH_INFO 
to route requests properly.

After that I didn't need to forward any header explicitly, and it works fine.
Let me know if this helps.

Reply via email to