Django not taking script name header from nginx -


i using django 1.8 way.

i trying deploy multiple django app @ same domain/subdomain different urls using script_name header.

my nginx config:

location /myapp/ {     proxy_pass http://127.0.0.1:8000/;     proxy_set_header script_name /myapp; } 

site loading conf request. meta['script_name'] empty when hover links, showing without 'myapp' in url.

any help?

i able partially resolve following snippet: http://flask.pocoo.org/snippets/35/

location /myapp {     proxy_pass http://127.0.0.1:8000;     proxy_set_header host $host;     proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;     proxy_set_header x-scheme $scheme;     proxy_set_header x-script-name /myapp;     } 

then created wsgi.py file in myapp folder with:

from django.core.wsgi import get_wsgi_application  _application = get_wsgi_application()  def application(environ, start_response):     script_name = environ.get('http_x_script_name', '')     if script_name:         environ['script_name'] = script_name         path_info = environ['path_info']         if path_info.startswith(script_name):             environ['path_info'] = path_info[len(script_name):]      scheme = environ.get('http_x_scheme', '')     if scheme:         environ['wsgi.url_scheme'] = scheme     return _application(environ, start_response) 

i had switch using

python manage.py runserver 0.0.0.0:8000 

for serving application using uwsgi. followed instructions @ setting django , web server uwsgi , nginx boiled down to

pip install uwsgi 

and serving django app

uwsgi --http :8000 --module myapp.wsgi 

edit: doesn't work static , media assets. see open ticket: https://code.djangoproject.com/ticket/25598


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -