> Hi,
>
> I'm not sure whether I have to change my django configuration or my
> nginx cofiguration.
> (Thus posted to gmane.comp.python.django.user and to
> gmane.comp.web.nginx.english)
>
> I have following setup:
>
> - nginx listening on https
> - most static contents like .css .js images served by nginx
> - everything else forwarded to django
>
> all .html files are in fact templated and should thus be treated by
> django. Additionally I wanted to grant access to the contents onlyy to
> authorized users.
>
>
> djangu urls.py setup
> -----------------------
>
> from django.contrib.auth.decorators import login_required
> from django.views.generic.simple import direct_to_template
>
>
>  url(r'^(?P<template>.*\.html)$',
>       login_required(direct_to_template),
>  ),
>
>
> nginx is configured with
> -------------------------
>
> location ~ \.*.html$ {
> uwsgi_pass django;
> uwsgi_param  QUERY_STRING       $query_string;
> uwsgi_param  REQUEST_METHOD     $request_method;
> uwsgi_param  CONTENT_TYPE       $content_type;
> uwsgi_param  CONTENT_LENGTH     $content_length;
>
> uwsgi_param  REQUEST_URI        $request_uri;
> uwsgi_param  PATH_INFO          $document_uri;
> uwsgi_param  DOCUMENT_ROOT      $document_root;
> uwsgi_param  SERVER_PROTOCOL    $server_protocol;
>
> uwsgi_param  REMOTE_ADDR        $remote_addr;
> uwsgi_param  REMOTE_PORT        $remote_port;
> uwsgi_param  SERVER_PORT        $server_port;
> uwsgi_param  SERVER_NAME        $server_name;
> }
>
> uwsgi is called with
> ----------------------
> uwsgi -s host:port  -H virtual_env_python --pidfile uwsgi.pid \
>     --pp ..-w wsgi_module
>
> The problem is, that the first request to
>
> https://mysite:myport/index.html
>
> is detected as non authenticated access. (that's what I want)
> and thus django tries to redirect to  redirected to the authentification
> page (that's also what I want)
> which should be
>
> Django should redirect to
> https://mysite:myport/accounts/login/?next=/index.html
>
> Unfortunately it redirects to
> http://mysite:myport/accounts/login/?next=/index.html
>
>
> Therefore I get the error message
> "400 Bad Request The plain HTTP request was sent to HTTPS port"
>
> Is there any variable that I can use to tell django, that the protocol
> is https and not http for the login pages
>
> Ideally I would like to have something like an nginx parameter being
> passed, such that django knows whether the request is coming from an
> nginx https server ( all redirects should be https:host:port )
> or from an nginx http server.
>
>
> Does anyone have a similiar setup or has some ideas?
>



You can force the protocol using the HTTPS variable (standard, but not
enabled in nginx) or you can force the protocol to htts using the
UWSGI_SCHEME variable

http://projects.unbit.it/uwsgi/wiki/uWSGIVars



-- 
Roberto De Ioris
http://unbit.it

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to