28 messages in ru.sysoev.nginxRe: Location problems
FromSent OnAttachments
Matteo NiccoliFeb 19, 2008 1:37 am 
Denis F. LatypoffFeb 19, 2008 2:22 am 
Matteo NiccoliFeb 19, 2008 2:38 am 
Igor ClarkFeb 19, 2008 3:04 am 
Denis F. LatypoffFeb 19, 2008 3:23 am 
Igor ClarkFeb 28, 2008 11:41 am 
Igor SysoevFeb 28, 2008 12:49 pm 
Igor ClarkFeb 29, 2008 1:38 am 
Igor SysoevFeb 29, 2008 2:41 am 
Igor ClarkFeb 29, 2008 3:13 am 
Igor SysoevFeb 29, 2008 3:30 am 
Igor ClarkFeb 29, 2008 7:36 am 
Cliff WellsFeb 29, 2008 11:20 pm 
Igor SysoevFeb 29, 2008 11:47 pm 
Igor ClarkMar 3, 2008 6:07 am 
Igor SysoevMar 3, 2008 6:15 am 
Igor ClarkMar 3, 2008 8:52 am 
Igor SysoevMar 3, 2008 8:55 am 
Igor ClarkMar 3, 2008 9:43 am 
Igor SysoevMar 3, 2008 9:49 am 
Igor ClarkMar 4, 2008 6:13 am 
Igor ClarkMar 6, 2008 9:40 am 
Igor SysoevMar 8, 2008 12:05 pm 
Igor ClarkMar 10, 2008 3:04 am 
Igor SysoevMar 10, 2008 3:28 am.method
Igor ClarkMar 10, 2008 3:51 am 
Igor ClarkMar 31, 2008 11:14 am.conf, .conf, .log
Igor ClarkApr 7, 2008 3:04 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Location problemsActions...
From:Igor Clark (igor@public.gmane.org)
Date:Feb 28, 2008 11:41:11 am
List:ru.sysoev.nginx

On 19 Feb 2008, at 11:23, Denis F. Latypoff wrote:

- location ~ /admin/.* { + location /admin { # not tested

Thanks Denis, and sorry for the delay in replying.

Unfortunately that didn't work, and I'm still having the same sort of problems with the location directive.

On another PHP site, I'm trying to restrict access to /admin via IP. I have the following config, which works fine, though perhaps not optimal:

server { listen 80; server_name server.name;

access_log /path/to/logs/access.log main; error_log /path/to//logs/error.log info;

location / { root /path/to//public; index index.php index.html;

# if requesting /, rewrite to frontend.php and stop rewrite ^/$ /frontend.php last;

# Set $control_path to $my_request_uri, in case there are any # custom rules above that might have changed it # Then, rewrite using the last rules if (!-e $request_filename) { rewrite ^/admin/(.*)$ /admin.php?CONTROL_PATH= $1 last; rewrite ^/speakers/(.+)/?$ /speakers/video/$1; rewrite ^/financethemes/(.+)/?$ /financethemes/ video/$1; rewrite ^/transcripts/(speaker|theme)/(.+)/?$ / transcripts/view/$1/$2; rewrite ^(.*)$ /frontend.php?CONTROL_PATH=$1 last; }

location ~ \.flv$ { flv; }

location /admin { allow 82.108.140.18; deny all; }

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9999 location ~ \.php$ { fastcgi_pass 127.0.0.1:9999; fastcgi_index index.php; fastcgi_intercept_errors on; include conf/fastcgi_params; } } error_page 404 /404.html; error_page 500 /500.html; }

I just want to do the following, but still have all the other directives work, so that rewrites and PHP work under /admin:

location /admin { allow 1.2.3.4; deny all; }

How should I go about this? Where should I put the /admin location block? Nothing I do seems to work. I understand that the first matched regular expression stops the search, but as I can't seem to get nesting locations to work, what should I do?

(By the way, this is the first time we've used the FLV module, and we're really pleased with the results, so thanks!)

Best wishes Igor

On 19 Feb 2008, at 11:23, Denis F. Latypoff wrote:

Hello Igor,

Tuesday, February 19, 2008, 5:04:48 PM, you wrote:

Hi folks,

I often have problems trying to use different locations without having to duplicate config. I think I must be thinking about it the wrong way!

Basically I just want to make /admin/ password-protected, but inherit all the other config.

So I tried this:

location / { include /path/to/php.conf; # includes all fastcgi stuff and some rewrites location ~ /admin/.* { auth_basic "Restricted"; auth_basic_user_file /path/to/ admin.htusers; } }

But it doesn't work, so I tried this way which I've made work before:

location / { include /path/to/php.conf; }

- location ~ /admin/.* { + location /admin { # not tested

auth_basic "Restricted"; auth_basic_user_file /path/to/admin.htusers; include /path/to/php.conf; }

But this doesn't work either, it includes the PHP file but doesn't do the auth, and there's no error in the log. I've tried various permutations on ~ /admin/.* too.

What am I doing wrong?

Many thanks, Igor