Require SSL for specific URLS

I’m wondering how I would go about creating a rule like this in NGINX.

I want certain paths to require HTTPS, and redirect to https:// if the
current schema is not https.

Now, to make it even better, I’m wondering if you visit a path NOT on
that HTTPS required list, how would I redirect it to http://



Posted at Nginx Forum:

Here is what I have so-far, but I’m not sure how to go back.

location ~ ^/(secure) {
if ($scheme = ‘http’) {
#Insecure, lets go to https
rewrite ^/(.*)$ https://$host/$1 permanent;

Posted at Nginx Forum: