Trouble adding /pma location to all virtual hosts

Ben Johnson ben at
Thu Jun 27 17:02:30 UTC 2013

On 6/27/2013 12:42 PM, Ben Johnson wrote:
> 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.
> Do I need to add something something like this to the location block?
>     rewrite ^$request_uri? permanent;
> (Ideally, I would like the "" part to be dynamic, so it works
> for all vhosts; would I use $host, $server_name? Something else entirely?)

I ended-up with this, and it seems to work as expected:

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.



More information about the nginx mailing list