Welcome! Log In Create A New Profile

Advanced

Re: Protect /analytics on Nginx with basic authentication, but allow access to .php and .js files??

February 12, 2015 04:11PM
> What actual requests are made that are challenged for
> authentication? Check your access_log for http 401.
>
> At a guess, it is just /analytics/piwik.js that you care about here.
>
> So: add
>
> location = /analytics/piwik.js {auth_basic off;}
>
> inside your "location /analytics {}" block.
>
> (This will try to serve the file "/var/www/piwik//piwik.js", given the
> above configuration.)

Wow. I feel so dumb. That worked perfectly! Below is the config I'm using to turn off authentication for piwik.js as well as .php files.

location /analytics {
alias /var/www/piwik/;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/pass;
try_files $uri $uri/ /index.php;
location = /analytics/piwik.js{
auth_basic off;
}
location ~* ^/analytics(.+\.php)$ {
auth_basic off;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Thank you!!!
Subject Author Posted

Protect /analytics on Nginx with basic authentication, but allow access to .php and .js files??

lmm5247 February 11, 2015 11:45AM

Re: Protect /analytics on Nginx with basic authentication, but allow access to .php and .js files??

Francis Daly February 11, 2015 03:22PM

Re: Protect /analytics on Nginx with basic authentication, but allow access to .php and .js files??

lmm5247 February 12, 2015 04:11PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 299
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready