Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Rewrite location and then proxy_pass

$
0
0
I'm having some difficulties rewriting a location to https, then asking if a specific cookie or IP is matched and then pass it to a http backend. For example, I need the /api location rewritten to https since the whole domain is just http and don't may be rewritten completely to https. My intention is something like this:

location ^~ /api {

rewrite https://$http_host$request_uri; (rewrite the location to https)

if ($iporcookiematches != 1) { (and then check if the ip or cookie matches)
return 403;
}

proxy_pass http://backend;
}

Does it make sense? Is it somehow possible?

Cheers,
Szop

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>