Nginx HTTPS when only matching admin subfolder
Posted
by
sebastyuiop
on Super User
See other posts from Super User
or by sebastyuiop
Published on 2012-09-12T04:14:11Z
Indexed on
2012/09/13
3:42 UTC
Read the original article
Hit count: 190
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
© Super User or respective owner