<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Hello,<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 27, 2013 at 1:02 PM, Ben Johnson <span dir="ltr"><<a href="mailto:ben@indietorrent.org" target="_blank">ben@indietorrent.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
<br>
On 6/27/2013 12:42 PM, Ben Johnson wrote:<br>
</div><div class="im">> I don't want PMA (anything within the /pma/ location) to be accessible<br>
> over a plaintext connection. In other words, I wish to force HTTPS.<br>
><br>
> Do I need to add something something like this to the location block?<br>
><br>
> rewrite ^ <a href="https://domain.com" target="_blank">https://domain.com</a>$request_uri? permanent;<br>
><br>
> (Ideally, I would like the "<a href="http://domain.com" target="_blank">domain.com</a>" part to be dynamic, so it works<br>
> for all vhosts; would I use $host, $server_name? Something else entirely?)<br>
<br>
</div>I ended-up with this, and it seems to work as expected:<br>
<br>
location ^~ /pma/ {<br>
root /var/www/;<br>
<br>
if ($scheme = http) {<br>
return 301 https://$server_name$request_uri;<br>
}<br>
<br>
# ...<br>
}<br>
<br>
If there's a better way of achieving the same, I'd love to be informed.<br></blockquote><div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline"><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">
I would have kept the <a href="http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite">rewrite</a> statement which was a good idea.</div> <div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">
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).<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">
Why would you replace it with a 'if' statement? <a href="http://wiki.nginx.org/IfIsEvil">http://wiki.nginx.org/IfIsEvil</a><br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153);display:inline">
I guess you can use the variables in the rewrite directive aswell.<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
<div class="HOEnZb"><div class="h5"><br>
-Ben<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font>
</div></div>