V
V
Vadim2015-08-01 01:43:51
Nginx
Vadim, 2015-08-01 01:43:51

How to select one route with http on a site with https?

Good day.
There is a site wrapped in https, there is only one page on it, on which there will be different iframes, which may very well not be https.
The next task is to show this page with https and a warning with a link to http (in fact, everything is done in the code), as well as to show it via http, redirecting the rest of the routes to https.
How it looks now:

server {
    server_name server.com;
    listen 80;

    location ~ ^/(hello|hello/.*)$ {
        uwsgi_pass  django;
        include  uwsgi_params; 
    }

    location / {
        rewrite  ^ https://$server_name$request_uri? permanent;
    }

}

server {
    listen      443 ssl spdy; 
    server_name server.com; 
    charset     utf-8; 

    # всякие настройки ssl, логи и прочая джанго-статика
  
    location / {    
        uwsgi_pass  django;
        include  uwsgi_params;
    }
}

The first visit to the /hello page is successful, the second time the redirect to https occurs.
There is a suspicion that this is to blame for everything in the port 80 server
location / {
    rewrite  ^ https://$server_name$request_uri? permanent;
}

what redirects the static and what the browser remembers the next time the page is refreshed.
But how to get around it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mib, 2015-08-01
@mib

Try
location / {
rewrite ^ https://$server_name$request_uri? redirect;
}

V
Vlad Zhivotnev, 2015-08-01
@inkvizitor68sl

do not use permanent, the 301 redirect is cached by the browser.
return 302 use.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question