Trouble adding /pma location to all virtual hosts

Ben Johnson ben at indietorrent.org
Fri Jun 28 18:03:08 UTC 2013



On 6/27/2013 7:13 PM, Francis Daly wrote:
> On Thu, Jun 27, 2013 at 01:02:30PM -0400, Ben Johnson wrote:
>> On 6/27/2013 12:42 PM, Ben Johnson wrote:
> 
> Hi there,
> 
>>> I don't want PMA (anything within the /pma/ location) to be accessible
>>> over a plaintext connection. In other words, I wish to force HTTPS.
> 
>> location ^~ /pma/ {
>>     root /var/www/;
>>
>>     if ($scheme = http) {
>>         return 301 https://$server_name$request_uri;
>>     }
>>
>>     # ...
>> }
>>
>> If there's a better way of achieving the same, I'd love to be informed.
> 
> The usual suggestion is that different server configurations best live
> in different server blocks.
> 
> You have other reasons not to want to do that here -- including the
> repetition aspect.
> 
> I'd say that what you have here is the best way.
> 
> 	f
> 

Hi, Francis,

I've taken your good advice and swapped

location ~* /webmail {
    return 301 /webmail/;
}

for

location = /webmail { return 301 /pma/; }
location = /WEBMAIL { return 301 /pma/; }
location = /WEBMAIL/ { return 301 /pma/; }

The latter form is simpler, its effect is obvious, and it seems less
prone to cause unexpected results if new locations are ever added.

On the whole, I've avoided top-level regex locations for the reason you
mentioned. Again, sound advice.

Everything else you say in your previous replies makes sense; you've
answered all of my questions (and then some!).

Excellent. Everything seems to be in good working order here.

Thanks again, Francis,

-Ben



More information about the nginx mailing list