Django URLs with/without proxy server

57 views
Skip to first unread message

Barun Saha

unread,
Mar 1, 2013, 10:57:40 AM3/1/13
to django...@googlegroups.com
I have two Django apps (say, app1 and app2) hosted on the same machine using Apache mod_wsgi. These two apps are hosted on two different environments:

 1. On a physical server where only these two apps are hosted. They are accessed as http://www.example.com/app1/app1/ and http://www.example.com/app2/app2/.
 2. In the second environment there is a proxy server. A separate web page on that server is accessed as http://www.domain.com/. This links to the above two apps (now hosted on a single virtual machine) as http://www.domain.com/id1/ and http://www.domain.com/id2/

The URLconf file looks like:

    urlpatterns = patterns('',
        (r'^admin/', include(admin.site.urls)),
        (r'^app1/', include('project.app1.urls')),      
    )

The problem is, this URL configurations works in the environment 1, but not in the environment 2. Now, if I do something *crazy* in the environment 2 such as 

     urlpatterns = patterns('',
        (r'^admin/', include(admin.site.urls)),
        (r'^app1/app1/app1/', include('project.app1.urls')),      
        (r'^app1/app1/', include('project.app1.urls')),      
        (r'^app1/', include('project.app1.urls')),      
     )

then the application works. In the env. 2, the app is accessed as http://www.domain.com/id1/app1/app1/.

I couldn't understand why we need to prefix app1 in the URL so many times. In other words, why (how) this works.

Could someone clarify on this? Also, note that all configurations need to be done on the virtual machine. I don't have access to the proxy server.

(Posted in Stackoverflow: http://stackoverflow.com/questions/15159134/django-urls-with-without-proxy-server)

Bill Freeman

unread,
Mar 2, 2013, 10:19:38 AM3/2/13
to django...@googlegroups.com
You haven't show project/app1/urls.py (or wherever you're getting project.app1.urls).  My guess is that it also specifies that each url begins with "app1/".  Since the root urlconf matches *and consumes* one "app1/" from the request path, any "app1/" required by app1's urls.py is required in addition.

Or isn't that your question?

Bill


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Barun Saha

unread,
Mar 4, 2013, 1:28:06 AM3/4/13
to django...@googlegroups.com
Bill,

The URLs in the file for app1 do not have such prefix. Following are two lines from project/app1/urls.py -- other URLs have similar structure, including that for app2.

urlpatterns = patterns('project.app1.views',
    url(r'^$',                                  'index',         name='index'),
    url(r'^(?P<object_id>\d+)/$',               'introduction',        name='introduction'),
)



--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/g-rUctm_0oY/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Bill Freeman

unread,
Mar 4, 2013, 9:44:45 AM3/4/13
to django...@googlegroups.com
I don't know then.  If it were me, at this point I'd be single stepping through the resolver code with pdb (runserver), or if the problem doesn't happen under runserver, adding logging calls to the url resolver code to see what it's doing where and when.
Reply all
Reply to author
Forward
0 new messages