Nginx HTTPS when only matching admin subfolder
- by sebastyuiop
I have managed to get all /admin requests redirected to https by:
server {
listen 80;
location /admin {
rewrite ^ https://$server_name$request_uri?$args permanent;
}
}
But can't figure out how to get all https requests that are not within /admin redirected to http, so far I have:
server {
listen 443;
location ~ /admin {
rewrite ^ http://$server_name$request_uri?$args permanent;
}
}
EDIT:
I have got the redirects working as required but can't stop the /admin url going to 404. It feels like I need to put something in the empty block.
server {
listen 443;
location /admin {
}
location / {
rewrite ^ http://$server_name$request_uri?$args permanent;
}
}
Thanks