2 domains for 2 apps on 1 web2p

54 views
Skip to first unread message

Vlad

unread,
Jun 14, 2019, 2:23:21 PM6/14/19
to web2py-users
I've had multiple apps in one web2py with no problems, of course, but only up to the point I've assigned different domains to different apps 

I am on PythonAnywhere, but presumably it's the same issue on any hosting. 

I am giving 2 cnames for 2 apps, and I pointed both cnames properly. BUT only one domain works for bare domain - i.e. for www.domain1.com . For the second name I always have to specify the full path  -www.domain2.com//app/cont/func.

I am obviously missing something, but here is why I have this problem: 

they all share one routes.py on the web2py root level. routes.py can only have one entry corresponding to "/" - I can point "/" to app1/cont1/func1. So, www.domain2.com can't be handled without a/c/f , because no matter what the domain is, the only proper entry for the bare domain name is "/" in routes.py.

How to handle this properly, i.e. to specify routing for each domain root - without having the 2nd web2py installation?



Vlad

unread,
Jun 14, 2019, 2:47:22 PM6/14/19
to web2py-users
let me be a bit more specific, as my problem is apparently in missing something very basic:

here is a quote from PythonAnywhere docs: "...for each additional domain name, you need to set up another PythonAnywhere web app from the web tab. This time though, you should choose "manual configuration". Then, go and edit your WSGI file. You should make it into a copy of the WSGI file for the first web2py application, so that both domains point at the same web2py installation. Then the web2py routes.py should work."

So this is perfect, and routes.py works indeed. However, it doesn't work fully for the root domains: 

routes.py can only have only entry corresponding to "/", for example: 

routes_in = (
   ( '/' ,' /app1/cont1/func1'),                                               
 )

This will take care of www.domain1.com .

Now, if I want to point www.domain2.com to /app2/conf2/func2 - I have no way to handle this (unless I am missing something very basic here). I would at least need to specify something like this:
 ( '/app2', '/app2/conf2/func2' ) which will take care of www.domain2.com/app2 but the root www.domain2.com will still be redirecting to /app1/cont1/func1, as per the only "/" entry in routes.py, as "/" doesn't distinguish between domains. 

What am I missing? How can I handle this properly?? 

Jim S

unread,
Jun 14, 2019, 3:01:51 PM6/14/19
to web2py-users
My production routes.py has this in it:

routers = dict(BASE=dict(domains={'www.domain1.com': 'app1',
                                 
'www.domain2.com': 'app2'}))



-Jim

Eliezer (Vlad) Tseytkin

unread,
Jun 14, 2019, 3:05:24 PM6/14/19
to web...@googlegroups.com
Oops I didn't know that domains can be there!
Thank you!!

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/GKiH_-0K8d8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/4e86e650-c228-496d-b0da-4eb0cb96ef45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jim Steil

unread,
Jun 14, 2019, 3:09:53 PM6/14/19
to web...@googlegroups.com
Glad to help, this is the only way I know manage the routing, I'd forgotten about the routes_in.

-Jim

Reply all
Reply to author
Forward
0 new messages