WebFactions Applications

52 views
Skip to first unread message

Web2Py Freak

unread,
Oct 30, 2011, 7:23:21 AM10/30/11
to web2py-users
Dear All ,

I am using WebFaction for hosting , i install the web2py app in a
custom script , now do i have to install an app for every website or
use just one app , and if using one app how can i point the domain to
it ??


Best Regards ,
Hassan Alnator

Ray (a.k.a. Iceberg)

unread,
Oct 30, 2011, 9:59:44 AM10/30/11
to web2py-users
Hi Hassan,

You use so many webfaction slang in your post. Fortunately I use
webfaction too so I can understand.

Yes I think you can install the entire web2py package as a "webfaction
app" for your each "webfaction website". But that way each "webfaction
app" contains at least one dedicate process. Your webfaction account
may exceed memory quota quickly.

I install only one web2py package as a one-for-all "webfaction app".
Then bind my several domains to this unique "webfaction app" via
webfaction control panel, so requests to all my domain go to that same
web2py process. Later, setup some url rewrite rules so requests for
different domain go to different "web2py app". This solution is good
for many light traffic sites.

Hope I describe it clearly.

Regards,
Ray


Web2Py Freak

unread,
Oct 30, 2011, 10:17:44 AM10/30/11
to web2py-users
i understand it but i really dont know how to do it

Web2Py Freak

unread,
Oct 30, 2011, 10:31:13 AM10/30/11
to web2py-users
My app name is 'Web2py' and in it i have two 'web2py app':

1- welcome
2-maestro

now i have a domain and in the site app i selected web2py and there is
nothing in the path so it takes the welcome app

and now i have some other domain and i want it to start mastro web2py
app .. i will select web2py and then what to add in the URL path ???

Ray (a.k.a. Iceberg)

unread,
Oct 30, 2011, 11:04:04 AM10/30/11
to web2py-users
If ALL your other domains only need ONE SAME "web2py app" named
mastro, you are lucky. You only need to rename "mastro" as "welcome"
or "init". Problem solved.

If, in my cases, different domain needs different web2py app to serve,
I use a naive trick. Here is my "web2py app" welcome/default.py 's
index():
Well, my simple

def index(): # serves as a springboard
if request.env.http_host.endswith('site_alpha.com'):
redirect(URL(a='alpha',c='default',f='index'))
if request.env.http_host.endswith('site_beta.com'):
redirect(URL(a='beta',c='default',f='index'))
...

You get the idea.

It is not perfect. End users see a long url, e.g.
http://www.site_alpha.com/alpha/default/index
Besides, if site alpha 's end user types in http://www.site_ALPHA.com/BETA/default/index,
oops, he sees contents in site beta. I can live with that. How about
you?

It is possible to use web2py's builtin url rewriting feature, or
nginx's url rewrite feature, which should be faster by the way. But I
did not go that far yet. People who've been there please give some
light.

Regards,
Ray

Anthony

unread,
Oct 30, 2011, 11:18:57 AM10/30/11
to web...@googlegroups.com
See here: http://web2py.com/book/default/chapter/04#Parameter-Based-System -- there's an example mapping domains to apps.

Vasile Ermicioi

unread,
Oct 30, 2011, 3:27:25 PM10/30/11
to web...@googlegroups.com
a few steps that I use, I assume that you already installed web2py :)
0) set your domain at your registrar to point to webfaction dns servers
1) add your domain to webfaction domains
2) set your domain to be handled by your app (see webfaction's websites)
3 )create a routes.py (or rename routes_example.py) file with the content

routes_in = (
('(.*):https?://(www\.)?yoursitename1\.com:(.*)/', '/yourapp1/'),
        ('(.*):https?://(www\.)?yoursitename2\.com:(.*)/', '/yourapp2/'),
 )


def __routes_doctest():
    pass

if __name__ == '__main__':
    import doctest
    from gluon.rewrite import *
    load(routes=__file__)
    doctest.testmod()

4) restart your server (apache, nginx or whatever server you use)

this kind of installation doesn't need multiple web2py's installations

Ray (a.k.a. Iceberg)

unread,
Oct 31, 2011, 1:09:09 AM10/31/11
to web2py-users
Thanks for the hint. I managed to come up with a seemingly simpler
routes.py for same purpose.

routers = dict(
BASE = dict(
domains = {
"my_domain.com" : "app1",
"another_domain.com" : "app2",
},
),
)

However, the only downside is only one said app is exposed to the said
domain. What if my domain need two apps to serve?

Regards,
Ray
Reply all
Reply to author
Forward
0 new messages