Nginx + uwsgi + Django: Error in url rewriting -


i'm trying deploy django project on under sub path of institute website.

let's server ip is: x1.x2.x3.x4.
, xyz.edu/tnp probably points x1.x2.x3.x4/portal/.

structure of django project this:

. |-- project |   |-- app1 |   |-- app2 |   |-- project_nginx.conf |   |-- project_uwsgi.ini |   |-- db.sqlite3 |   |-- manage.py |   |-- media  |   |-- readme.md |   |-- static |   `-- uwsgi_params |-- readme.md |-- requirements |   |-- base.txt |   |-- dev.txt |   |-- prod.txt |   `-- test.txt |-- requirements.txt |-- static_cdn |   |-- admin |   ..... 

and url scheme in project/urls.py looks this:

 url(r'^app1/', include('app1.urls')),  url(r'^app2/', include('app2.urls')),  url(r'^admin/', include(admin.site.urls)), 

on local server, following scheme working perfectly.
* 127.0.0.1:8000/app1/
* 127.0.0.1:8000/app1/login/
* 127.0.0.1:8000/app1/homepage/
* 127.0.0.1:8000/app2/somepage
* 127.0.0.1:8000/admin/

i want map urls on deployment server, that
xyz.edu/tnp/app1 links x1.x2.x3.x4/portal/app1 and
xyz.edu/tnp/app2 links x1.x2.x3.x4/portal/app2 xyz.edu/tnp/admin links x1.x2.x3.x4/portal/admin
, on.

the problem suffix portal in x1.x2.x3.x4/portal/. when type xyz.edu/tnp/app1 in browser, error i'm receiving

using urlconf defined in portal.urls, django tried these url patterns, in order:

^app1/
^app2/
^media/(?p.)$
^static/(?p.
)$

the current url, portal/app1/, didn't match of these.

now think of 2 approaches:

  1. manually prepend portal urls in project/urls.py

  2. drop prefix portal in portal_nginx.conf file.

first approach isn't working internal urls. index page apps, i.e. app1, app2 , on, working fine other urls, being rendered xyz.edu/portal/login instead of xyz.edu/tnp/app1/login.

second approach, mentioned here , here, seems promising, not working me. maybe i'm doing wrong. following project_nginx.conf , project_uwsgi.ini files.

project_uwsgi.ini

[uwsgi]  chdir           = ... # django's wsgi file module          = project.wsgi # virtualenv (full path) home            = ...  # master master          = true # maximum number of worker processes processes       = 10 # socket (use full path safe socket          = ... # clear environment on exit vacuum          = true 

project_nginx.conf

upstream django {     server unix://.../.../project.sock; # file socket     # server 127.0.0.1:8001;  }  # configuration of server server {     listen      80;     server_name xyz.edu; # substitute machine's ip address or fqdn     client_max_body_size 75m;   # adjust taste      # django media     location /media  {         alias /usr/share/nginx/.../project/media;     }      location /static {         alias /usr/share/nginx/.../project/static;     }      # finally, send non-media requests django server.     location /portal/ {         rewrite /portal/(.*) /$1  break;         uwsgi_pass  django;         # # uwsgi_params file installed         include     /usr/.../wsgi_param         # uwsgi_param script_name /portal/;         # uwsgi_modifier1 30;       } } 


Comments

Post a Comment

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -