Welcome! Log In Create A New Profile

Advanced

Disabling basic_auth with rewrites

May 19, 2011 09:59AM
Hi,

I would like to generally protect my site but allow one certain path. However, I need rewrites to forward the requested path to a PHP file. Unfortunately the following does not work:

location ~ ^/feeds/importer/.* {
auth_basic off;
rewrite ^/(.*)$ /index.php?q=$1;
}

location ~ \.php$ {
auth_basic "protected";
auth_basic_user_file /etc/nginx/htpasswd/protected;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass $socket;
# workaround as fastcgi_param cannot be used inside if statements
set $https off;
if ($scheme = https) {
set $https on;
}
fastcgi_param HTTPS $https;
fastcgi_read_timeout 6000;
}

location ~ ^/(.*) {
auth_basic "protected";
auth_basic_user_file /etc/nginx/htpasswd/protected;
try_files $uri /index.php?q=$1&$args;
}

Any ideas how to unprotect the first location?
Subject Author Posted

Disabling basic_auth with rewrites

klausi May 19, 2011 09:59AM

Re: Disabling basic_auth with rewrites

Maxim Dounin May 19, 2011 10:10AM

Re: Disabling basic_auth with rewrites

klausi May 19, 2011 12:43PM

Re: Disabling basic_auth with rewrites

Maxim Dounin May 19, 2011 02:12PM

Re: Disabling basic_auth with rewrites

Igor Sysoev May 19, 2011 03:18PM

Re: Disabling basic_auth with rewrites

Maxim Dounin May 20, 2011 04:02AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 156
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