Webfaction account with multiple apps under 1 web2py install

166 views
Skip to first unread message

Jim Steil

unread,
Feb 1, 2012, 5:14:05 PM2/1/12
to web...@googlegroups.com
Hi

I've got a couple different apps I want to deploy under my web2py
instance on webfaction. Unfortunately, I'm well versed in routing and
knowing how to route different requests to different apps.

I have different urls that I'd like mapped to different apps.

www.application1.com I would like to point to
web2py/applications/application1
www.application2.com I would like to point to
web2py/applications/application2

And, if possible, I prefer to not show the application name in the url
-> www.application1.com/application1/controller/function

Controller and function are fine but would prefer to eliminate the
duplicate application1. If there is a spot in the manual I should study
harder, please reference it. Unfortunately, I'm relatively weak when it
comes to url rewriting/routing and regular expressions.

-Jim

Vasile Ermicioi

unread,
Feb 2, 2012, 4:22:03 AM2/2/12
to web...@googlegroups.com
I will show what I use

in routes.py I have:

routes_in = (
#('/admin/(.*)', '/admin/$1'),
('(.*):https?://(www\.)?site1\.com:(.*)/', '/site1/'),
        ('(.*):https?://(www\.)?site2\.com:(.*)/', '/site2/'),
)

after you change routes.py you need to restart your server (apache, or whatever you use)
if you use uwsgi and started it with touch-reload option you only need to touch the file that you passed 
touch tmp/uwsgireload.txt

if you need more 

Martín Mulone

unread,
Feb 2, 2012, 5:26:48 AM2/2/12
to web...@googlegroups.com

Take a look to the router.py in web2py root folder, to use it you have to rename it to routes.py

1.
2.
3.
4.
5.
6.
7.
8.
routers = dict(
BASE = dict(
domains = {
'domain1.com' : 'app1',
'domain2.com' : 'app2',
}
),
)



2012/2/1 Jim Steil <j...@qlf.com>

Jim Steil

unread,
Feb 2, 2012, 9:24:52 AM2/2/12
to web...@googlegroups.com
Wow,  beautiful and simple. 

Thanks Martin, I really appreciate it.

    -Jim

Jim Steil

unread,
Feb 2, 2012, 9:25:45 AM2/2/12
to web...@googlegroups.com
Vasile - Thanks for the reply - However, with my aversion to regular expressions, I chose to use the solution that Martin provided. 

Thanks again.

    -Jim

Vasile Ermicioi

unread,
Feb 2, 2012, 11:09:32 AM2/2/12
to web...@googlegroups.com
Vasile - Thanks for the reply - However, with my aversion to regular expressions, I chose to use the solution that Martin provided.  
 
no problem :)

Kenneth

unread,
May 1, 2013, 8:54:34 AM5/1/13
to web...@googlegroups.com
I am using the routers.domains method to routing the applications to domains, 
I have a problem that I can access to the applications which are not routed to the assigned domain.

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

domain2.com still has the access to app1.

Should I just block the applications when users request the unassigned applications from the controller?

Thank you

Loïc

unread,
May 1, 2013, 9:48:31 AM5/1/13
to web...@googlegroups.com
Did you restart your webserver / reload routes?

I use a similar routes.py for multiple domains and it works fine.
Maybe you could try :

routers = dict(
  BASE  
= dict(
      domains
= {

           
'www.domain1.com' : 'app1',
           
'domain1.com' : 'app1',
           
'www.domain2.com' : 'app2',
           
'domain2.com' : 'app2',
     
},
      applications
=['app1', 'app2']
 
),
)

Kenneth

unread,
May 1, 2013, 9:54:08 AM5/1/13
to web...@googlegroups.com
Yeah. I follow the same pattern.
Could you try to browse "www.domain1.com/app2" to see if it doesn't direct to app2? Mine does. hmm

Loïc

unread,
May 1, 2013, 9:59:41 AM5/1/13
to web...@googlegroups.com
You're right.
On my webserver :

www.domain1.com redirects to app1 ==> OK
www.domain2.com redirects to app2 ==> OK

but

www.domain1.com/app2 redirects to app2, and I don't understand why...

Kenneth

unread,
May 1, 2013, 10:51:31 AM5/1/13
to web...@googlegroups.com
:) Thank you for trying, Loic!

Should I just ignore this concern? I am not too concerned about this but I would like to learn about how to solve this problem.

Loïc

unread,
May 1, 2013, 12:37:11 PM5/1/13
to web...@googlegroups.com
I would like to understand too...
Maybe somebody else has an idea ?

Loïc

unread,
May 1, 2013, 12:37:20 PM5/1/13
to web...@googlegroups.com

Kenneth

unread,
May 1, 2013, 2:53:39 PM5/1/13
to web...@googlegroups.com
+1 !!

Anthony

unread,
May 1, 2013, 3:29:02 PM5/1/13
to web...@googlegroups.com
What if you add exclusive_domain=True to the BASE dict? I believe that prevents creating outgoing URLs like that, but not sure if it affects incoming requests.

Anthony

Kenny Chung

unread,
May 1, 2013, 6:54:09 PM5/1/13
to web...@googlegroups.com
Thank you as always, Anthony. Working great. ;)


--
 
---
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/1hSkZ4o99h4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages