Il 2014-02-13 06:16 zhenwu he ha scritto:
> Thanks for your help, Luca.
>
> Could you elaborate a little bit? I am kind of new to this kind of
> thing. What I am doing is that, I am using django to redirect all url
> calls to python API to handle something and then return as response.
> you want me to redirect this http call to where? and where do I setup
> this redirect? in django? BTW, I am using manage.py run server 0:xxxx,
> and it started listening to http port.
I'm guessing you have already setup your Django app behind a webserver
(Apache, nginx + uwsgi, whatever).
I'm also assuming you have already set up an HTTPS virtualhost in your
webserver to serve at least your REST API urls.
If I understand correctly, you want to avoid API access using standard
HTTP. So what you can do is, when accessing any webservice URL, redirect
the request via HTTP 301 to the equivalent HTTPS url.
With nginx you can easily do this in your HTTP virtualhost configuration
with something like
...
location /your-REST-URL-endpoint {
rewrite ^(.*)
https://www.example.com$1 permanent;
}
...
ciao
Luca