Answer the question
In order to leave comments, you need to log in
Nginx and forced redirect to https?
Actually, it became necessary to redirect users of one resource forcibly to https due to some delicacy of the information that is available on the resource.
Is there such a hat in the wirthost config:
location /somewhere {
rewrite ^/(.*) https://$server_name$request_uri ? permanent;
}
Considering that a separate virthost was configured for access via https a long time ago (in a separate file), I just threw these two and a half lines into the virthost running on port 80, and everything turned out fine, it would seem.
The downside is that users love bookmarks. If you tell the browser resource.ru/somewhere , then a redirect to a secure connection will work. If we sayresource.ru/somewhere/index.php , or show your hands to the desired script, the redirect does not work.
How could the desired be realized?
Wednesday - Squeeze, nginx 1.0.10 and php5-fpm 5.3.8-1 from dotdeb. The rest, I think, is irrelevant.
Answer the question
In order to leave comments, you need to log in
Try outside of location like this:
server {
server_name ...;
rewrite ^(/somewhere/.*)$ https://$host$1 permanent;
...
}
location ~* ^/somewhere(.*) {
rewrite ^/(.*) https://$server_name$request_uri? permanent;
}
rewrite ^/somewhere(.*) https://$server_name/somewhere$1 permanent;
If you need a specific section.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question