with nginx: http to https and only some paths to http with different ports
<p>I want to have all http to https and only some paths to http with different ports:</p>

<pre><code>server { 
  listen 80; 
  servername _; 
  return 301 https://$host$requesturi;

  location /bamboo { 
    rewrite ^/bamboo(.*)$ http://mydomainname:8085/$1 last; 
  }

  location /api { 
    rewrite ^/api(.*)$ http://mydomainname:8080/$1 last; 
  }

  return 403; 
}
</code></pre>

<p>the above does not work,
also this does not work:</p>

<pre><code>#Redirect paths
server {
listen 443;
server_name _;

  location /bamboo {
    rewrite ^/bamboo(.*)$ http://mydomainname:8085/$1 last;
  }

  location /api {
    rewrite ^/api(.*)$ http://mydomainname:8080/$1 last;
  }

  return 403;
}

#Redirect http -&gt; https 
server { 
  listen 80; 
  servername _; 
  return 301 https://$host$requesturi;

  return 403;
}
</code></pre>

<p>Is there another way maybe of having all http send to https except these 2 paths?</p>