<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>On 19 Feb 2008, at 11:23, Denis F. Latypoff wrote:<blockquote type="cite"></blockquote><br><blockquote type="cite">-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location ~ /admin/.* {<br>+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location /admin { # not tested<br></blockquote><div><font class="Apple-style-span" color="#144FAE"><br class="webkit-block-placeholder"></font></div></div><div>Thanks Denis, and sorry for the delay in replying.</div><div><br class="webkit-block-placeholder"></div><div>Unfortunately that didn't work, and I'm still having the same sort of problems with the location directive.</div><div><br class="webkit-block-placeholder"></div><div>On another PHP site, I'm trying to restrict access to /admin via IP.</div><div>I have the following config, which works fine, though perhaps not optimal:</div><div><br class="webkit-block-placeholder"></div><div><div><div></div><blockquote type="cite"><div>&nbsp;&nbsp; &nbsp;server {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp;80;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;server_name<span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">server.name;</span></div><div><br class="webkit-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;access_log<span class="Apple-tab-span" style="white-space:pre">        </span>/path/to/logs/access.log<span class="Apple-tab-span" style="white-space:pre">        </span>main;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;error_log<span class="Apple-tab-span" style="white-space:pre">        </span>/path/to//logs/error.log<span class="Apple-tab-span" style="white-space:pre">                </span>info;</div><div><br class="webkit-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;location / {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root<span class="Apple-tab-span" style="white-space: pre; ">                </span>/path/to//public;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;index<span class="Apple-tab-span" style="white-space: pre; ">                </span>index.php index.html;</div><div><br class="webkit-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# if requesting /, rewrite to frontend.php and stop</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite<span class="Apple-tab-span" style="white-space: pre; ">        </span>^/$<span class="Apple-tab-span" style="white-space: pre; ">        </span>/frontend.php last;</div><div><br class="webkit-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Set $control_path to $my_request_uri, in case there are any</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# custom rules above that might have changed it</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Then, rewrite using the last rules</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!-e $request_filename) {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite<span class="Apple-tab-span" style="white-space: pre; ">        </span>^/admin/(.*)$<span class="Apple-tab-span" style="white-space: pre; ">                                                        </span>/admin.php?CONTROL_PATH=$1 last;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite<span class="Apple-tab-span" style="white-space: pre; ">        </span>^/speakers/(.+)/?$<span class="Apple-tab-span" style="white-space: pre; ">                                        </span>/speakers/video/$1;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite<span class="Apple-tab-span" style="white-space: pre; ">        </span>^/financethemes/(.+)/?$<span class="Apple-tab-span" style="white-space: pre; ">                                </span>/financethemes/video/$1;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite<span class="Apple-tab-span" style="white-space: pre; ">        </span>^/transcripts/(speaker|theme)/(.+)/?$<span class="Apple-tab-span" style="white-space: pre; ">        </span>/transcripts/view/$1/$2;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite<span class="Apple-tab-span" style="white-space: pre; ">        </span>^(.*)$<span class="Apple-tab-span" style="white-space: pre; ">                                                                </span>/frontend.php?CONTROL_PATH=$1 last;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br class="webkit-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;location ~ \.flv$ {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;flv;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br class="webkit-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;location /admin {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;allow &nbsp; 82.108.140.18;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deny &nbsp; &nbsp;all;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br class="webkit-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9999</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;location ~ \.php$ {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_pass<span class="Apple-tab-span" style="white-space: pre; ">                                </span>127.0.0.1:9999;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_index<span class="Apple-tab-span" style="white-space: pre; ">                        </span>index.php;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_intercept_errors<span class="Apple-tab-span" style="white-space: pre; ">        </span>on;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;include<span class="Apple-tab-span" style="white-space: pre; ">                                        </span>conf/fastcgi_params;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;error_page &nbsp;404 &nbsp; &nbsp; &nbsp; &nbsp; /404.html;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;error_page &nbsp;500 &nbsp; &nbsp; &nbsp; &nbsp; /500.html;</div><div>&nbsp;&nbsp; &nbsp;}</div></blockquote><div><br></div></div></div><div>I just want to do the following, but still have all the other directives work, so that rewrites and PHP work under /admin:</div><div><br class="webkit-block-placeholder"></div><div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;location /admin {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;allow &nbsp; 1.2.3.4;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;deny &nbsp; &nbsp;all;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br class="webkit-block-placeholder"></div></div><div>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?</div><div><br></div><div>(By the way, this is the first time we've used the FLV module, and we're really pleased with the results, so thanks!)</div><div><br class="webkit-block-placeholder"></div><div>Best wishes</div><div>Igor</div><div><br><div><div>On 19 Feb 2008, at 11:23, Denis F. Latypoff wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hello Igor,<br><br>Tuesday, February 19, 2008, 5:04:48 PM, you wrote:<br><br><blockquote type="cite">Hi folks,<br></blockquote><br><blockquote type="cite">I often have problems trying to use different locations without having &nbsp;<br></blockquote><blockquote type="cite">to duplicate config.<br></blockquote><blockquote type="cite">I think I must be thinking about it the wrong way!<br></blockquote><br><blockquote type="cite">Basically I just want to make /admin/ password-protected, but inherit &nbsp;<br></blockquote><blockquote type="cite">all the other config.<br></blockquote><br><blockquote type="cite">So I tried this:<br></blockquote><br><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location / {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include /path/to/php.conf; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# includes all fastcgi stuff and some &nbsp;<br></blockquote><blockquote type="cite">rewrites<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location ~ /admin/.* {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_basic &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Restricted";<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_basic_user_file &nbsp;&nbsp;&nbsp;/path/to/admin.htusers;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></blockquote><br><blockquote type="cite">But it doesn't work, so I tried this way which I've made work before:<br></blockquote><br><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location / {<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include /path/to/php.conf;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></blockquote><br>- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location ~ /admin/.* {<br>+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location /admin { # not tested<br><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_basic &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Restricted";<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;auth_basic_user_file &nbsp;&nbsp;&nbsp;/path/to/admin.htusers;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include /path/to/php.conf;<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br></blockquote><br><blockquote type="cite">But this doesn't work either, it includes the PHP file but doesn't do &nbsp;<br></blockquote><blockquote type="cite">the auth, and there's no error in the log. I've tried various &nbsp;<br></blockquote><blockquote type="cite">permutations on ~ /admin/.* too.<br></blockquote><br><blockquote type="cite">What am I doing wrong?<br></blockquote><br><blockquote type="cite">Many thanks,<br></blockquote><blockquote type="cite">Igor<br></blockquote><br><blockquote type="cite">--<br></blockquote><blockquote type="cite">Igor Clark // POKE // 10 Redchurch Street // E2 7DD // +44 (0)20 7749 &nbsp;<br></blockquote><blockquote type="cite">5355 // <a href="http://www.pokelondon.com">www.pokelondon.com</a><br></blockquote><br><br><br>-- <br>Best regards,<br> Denis &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="mailto:denis@gostats.ru">mailto:denis@gostats.ru</a><br><br><br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Igor Clark // POKE // 10 Redchurch Street // E2 7DD // +44 (0)20 7749 5355 // <a href="http://www.pokelondon.com">www.pokelondon.com</a></div><div><br></div></div></div></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"> </div><br></div></body></html>