Assuming you have the routes described above and this in routes.conf

----- BEGIN routes.conf-------
domain1.com /app1/default
domain2.com /app2/default
----- END ----------

you would need this in apache config file:

<VirtualHost *.domain1.com:
80>
  WSGIDaemonProcess web2py user=www-data group=www-
data
  WSGIProcessGroup
web2py
  WSGIScriptAlias / /home/www-data/web2py/
wsgihandler.py

  <Directory /home/www-data/
web2py>
    AllowOverride
None
    Order
Allow,Deny
    Deny from
all
    <Files
wsgihandler.py>
      Allow from
all
    </
Files>
  </
Directory>

  AliasMatch ^/static/(.*)
\
           /home/www-data/web2py/applications/app1/static/
$1
  <Directory /home/www-data/web2py/applications/app1/static/
>
    Options -
Indexes
    Order
Allow,Deny
    Allow from
all
  </
Directory>

  <Location /
admin>
  Deny from
all
  </
Location>

  <LocationMatch ^/
appadmin>
  Deny from
all
  </
LocationMatch>

  CustomLog /var/log/apache2/access.log
common
  ErrorLog /var/log/apache2/
error.log
</VirtualHost>


<VirtualHost *.domain2.com:
80>
  WSGIDaemonProcess web2py user=www-data group=www-
data
  WSGIProcessGroup
web2py
  WSGIScriptAlias / /home/www-data/web2py/
wsgihandler.py

  <Directory /home/www-data/
web2py>
    AllowOverride
None
    Order
Allow,Deny
    Deny from
all
    <Files
wsgihandler.py>
      Allow from
all
    </
Files>
  </
Directory>

  AliasMatch ^/static/(.*)
\
           /home/www-data/web2py/applications/app2/static/
$1
  <Directory /home/www-data/web2py/applications/app2/static/
>
    Options -
Indexes
    Order
Allow,Deny
    Allow from
all
  </
Directory>

  <Location /
admin>
  Deny from
all
  </
Location>

  <LocationMatch ^/
appadmin>
  Deny from
all
  </
LocationMatch>

  CustomLog /var/log/apache2/access.log
common
  ErrorLog /var/log/apache2/
error.log
</VirtualHost>


On Oct 24, 4:39 pm, VP <vtp2...@gmail.com> wrote:
> Massimo,
> Can you please show us more specifically how to do this?   (I think
> someone also asked the same question in a previous topic).
>
> Thanks.
>
> On Oct 24, 1:25 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > This assumes web2py is serving static files. But it does not prevent
> > you to use a apache for it.
> > In this case you would need the virtual hosts for the different apps.
>
> > On Oct 24, 1:18 pm, VP <vtp2...@gmail.com> wrote:
>
> > > Can Massimo or someone clarify if this tip will result in web2py
> > > serving static files or Apache serving static files?
>
> > > Is this a "production" (high-performance) set up?  The assumption "one
> > > domain per app" appears to suggest that this is a production set up.
> > > Yet, Massimo mentioned in an early tip similar to this that web2py
> > > would be serving static files, and is thus not meant for production.
>
> > > Can someone clarify please?
>
> > > Thank you.
>
> > > On Oct 17, 9:03 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > Replace your web2py/routes.py with this:
>
> > > > ------------- begin routes.py-----------
> > > > try: config=open('routes.conf','r').read()
> > > > except: config=''
> > > > def auto_in(apps):
> > > >     routes=[
> > > >         ('/robots.txt','/welcome/static/robots.txt'),
> > > >         ('/favicon.ico','/welcome/static/favicon.ico'),
> > > >         ('/admin$a','/admin$a'),
> > > >         ]
> > > >     for a,b in [x.strip().split() for x in apps.split('\n') \
> > > >         if x.strip() and not x.strip().startswith('#')]:
> > > >         if not b.startswith('/'): b='/'+b
> > > >         if b.endswith('/'): b=b[:-1]
> > > >         app = b.split('/')[1]
> > > >         routes+=[
> > > >             ('.*:https?://(.*\.)?%s:$method /' % a,'%s' % b),
> > > >             ('.*:https?://(.*\.)?%s:$method /static/$a' % a,'%s/static/
> > > > $a' % app),
> > > >             ('.*:https?://(.*\.)?%s:$method /appadmin/$a' % a,'%s/
> > > > appadmin/$a' % app),
> > > >             ('.*:https?://(.*\.)?%s:$method /$a' % a,'%s/$a' % b),
> > > >             ]
> > > >     return routes
>
> > > > def auto_out(apps):
> > > >     routes=[]
> > > >     for a,b in [x.strip().split() for x in apps.split('\n') \
> > > >         if x.strip() and not x.strip().startswith('#')]:
> > > >         if not b.startswith('/'): b='/'+b
> > > >         if b.endswith('/'): b=b[:-1]
> > > >         app = b.split('/')[1]
> > > >         routes+=[
> > > >             ('%s/static/$a' % app,'static/$a'),
> > > >             ('%s/appadmin/$a' % app, '/appadmin/$a'),
> > > >             ('%s/$a' % b, '/$a'),
> > > >             ]
> > > >     return routes
>
> > > > routes_in=auto_in(config)
> > > > routes_out=auto_out(config)
> > > > ------------------- END ---------------
>
> > > > what does it do? It writes routes for you based on a simpler routing
> > > > configuration file called routes.conf. here is an example:
>
> > > > ----- BEGIN routes.conf-------
> > > > 127.0.0.1       /examples/default
> > > > domain1.com /app1/default
> > > > domain2.com /app2/default
> > > > domain3.com /app3/default
> > > > ----- END ----------
>
> > > > It maps a domain (the left had side) into an app and it shortens the
> > > > URLs for the app, by removing the listed path prefix. That means
>
> > > >http://domain1.com/indexwillbemappedinto  
> > > >/app1/default/indexhttp://domain2.com/indexwillbemappedinto  
> > > >/app2/default/index
>
> > > > It is safe in that it preserves admin, appadmin, static files,
> > > > favicon.ico and robots.txt.
>
> > > >http://domain1.com/favicon.icohttp://domain1.com/robots.txthttp://dom......
> > > >   /admin/...http://domain1.com/appadmin/...  
> > > >/app1/appadmin/...http://domain1.com/static/...  /app1/static/...
>
> > > > and vice-versa.
>
> > > > It does assume one app per domain.
>
> > > > I think something like this should be default since lots of people
> > > > find routes.py hard to work with.
> > > > Comments? Suggestions?
>
> > > > Massimo
>
>

Reply via email to