Trouble adding /pma location to all virtual hosts
B.R.
reallfqq-nginx at yahoo.fr
Thu Jun 27 17:15:44 UTC 2013
Hello,
On Thu, Jun 27, 2013 at 1:02 PM, Ben Johnson <ben at indietorrent.org> wrote:
>
>
> 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 ^ https://domain.com$request_uri? permanent;
> >
> > (Ideally, I would like the "domain.com" 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.
>
I would have kept the
rewrite<http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite>statement
which was a good idea.
The produced redirect is always a 301 (not 302) when the replacement
string starts with http(s) (check the doc page to which I provide the
link).
Why would you replace it with a 'if' statement?
http://wiki.nginx.org/IfIsEvil
I guess you can use the variables in the rewrite directive aswell.
>
> Thanks,
>
> -Ben
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
---
*B. R.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130627/4bc14fcc/attachment-0001.html>
More information about the nginx
mailing list