nginx subdir basic auth + php-fpm fastcgi

その場に書いたり locationの中にlocationを描いてその中にfastcgiと書く方法は利用出来ませんでした。

http://stackoverflow.com/questions/16779131/nginx-basic-auth-and-subfolders

こちらのように一旦try_filesでパラメーターを設定する方法で上手く行きました。

こんな感じで user 以下にはbasic 認証が反映されました。
location ~ ^/user/* {
auth_basic "user area";
auth_basic_user_file /home/appname/app/conf/httpd/passwd;
try_files $uri @rewriteapp;
}
location / {
index index.php index.html;
try_files $uri @rewriteapp;
}
location @rewriteapp{
rewrite ^/.*$ /index.php last;
}
location /index.php {
fastcgi_pass unix:/var/run/php-fpm/www.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/appiine/web$fastcgi_script_name;
include fastcgi_params;
}

This entry was posted on 月曜日, 5月 26th, 2014 at 3:59 PM and is filed under nginx, php. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。