This is really funny...

Jadi gw sedang mencoba membuat http auth untuk file info.php di nginx, namun tidak bisa jalan. Setiap file info.php tersebut diakses tidak keluar login. Untuk http auth per direktori sih bisa...

Sebagai informasi, dulu gw bisa buat http auth hanya untuk 1 file saja di nginx. Tapi sekarang gw lupa caranya dan installasinya udah dihapus pula jadi gak bisa di contek. Coba googling ketemu beberapa cara tapi gak ada yang bisa berjalan.


BTW ini file /sites-enabled/default gw

Code:

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$uri&$args;
# include /etc/nginx/naxsi.rules
}

#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}

#error_page 404 /404.html;

#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}

location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}

location ~*/info\.php$ {
auth_basic "asd";
auth_basic_user_file /usr/share/nginx/html/htpasswd;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
}

nginx 1.4.4, Wheezy, PHP 5.5

nginx dan PHP jalan di mode non previleges. User: www-data, group: www-data, id: 10000, seluruh file yg ada di root sudah chown ke www-data, PHP basedir aktif di /usr/share/nginx/html dan /tmp