Monday, August 6, 2012

Re: Dynamically adjusting STATIC_URL depending on http or https requests?

On 6-8-2012 17:56, Mark Gemmill wrote:
> I am not sure how that would work. Remember, this is a single instance of
> django - i.e. I'm not running the https/admin part of the
> site as a separate instance and therefore have only one settings file.
>
> What I came up with so far was to create 2 static url settings:
>
> *STATIC_URL = 'https://secureded/admin/static/'*
> *NON_SECURE_STATIC_URL = 'http://non/admin/static/'*

Do you require the server name in STATIC_URL, meaning they're served on
a different hostname? If so, you can still solve your problem with nginx
rewrite module:
server {
# normal server, listen params etc
location /static/ {
rewrite ^/(.*)$ http://non/$1 last;
}
}
server {
# ssl, listen params, ssl params
location /static/ {
rewrite ^/(.*)$ https://secured/$1 last;
}
}

Then in settings.py:
STATIC_URL = '/static/'
--
Melvyn Sopacua

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate