vhosts - apache - multiple domains - virtual hosts

121 views
Skip to first unread message

Olympus Runner

unread,
Jun 26, 2011, 4:02:28 AM6/26/11
to web2py-users
Hi,

I have one server and one IP address. I use Ubuntu 10.04 with Apache
and Web2py.
I have the default installation working.

I have the following domain names:

castle.example.com
www.demonstration.com

So here is my problem... I want to use Apache and Virtual Hosts for
multiple domains. I want to map the "myapp2" to www.demonstration.com.
It does work but it seems the user controller gets an error [invalid
controller (user/index) ]

Here are my vhosts:

################################################
################################################
# castle.example.com
################################################
################################################

<VirtualHost *:80>
ServerName castle.example.com
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/$1/static/$2
<Directory /home/www-data/web2py/applications/*/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 *:443>
ServerName rhegium.elitism.net
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/self_signed.cert
SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key

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/$1/static/$2

<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 hour"
Order Allow,Deny
Allow from all
</Directory>

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




################################################
################################################
# www.demonstration.com
################################################
################################################

<VirtualHost *:80>
ServerName demonstration.com
ServerAlias www.demonstration.com
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py/myapp2

<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/$1/static/$2
<Directory /home/www-data/web2py/applications/*/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/www_demonstration_com-access.log common
ErrorLog /var/log/apache2/www_demonstration_com-error.log
</VirtualHost>



################################################
################################################
################################################
################################################


Going to castle.example.com works perfectly.

Going to www.demonstration.com works and the default index controller
shows
"1. You visited the url /myapp2/ "

Whenever I click on a controller/view that requires auth_login I get
an invalid request error.
It takes me directly to the following:
http://www.demonstration.com/myapp2/default/user/login

If I fanangle with the url, the following works:
http://www.demonstration.com/default/user/login

Do I need to do something with my vhost file? Maybe something with
routes?
Is there an auth.settings I need to change?

my request.env.http_host did come up with "www.demonstration.com"
I think I need to override an Auth setting but I don't know if I am on
the right track.

Any help would be greatly appreciated...

Kenneth Lundström

unread,
Jun 26, 2011, 12:51:24 PM6/26/11
to web...@googlegroups.com
Hello,

I think the best way is to let Apache take care of sort out web2py
domains and non web2py domains. If you want to have a PHP site on one
vhost and the rest are web2py then you need two vhost files. All web2py
domains are pointed towards webpy.

Web2py with routes.py takes care of which domain belongs to which app.
This is my routes.py

routers = dict(
BASE = dict(
# abc = None,
domains = {
'economy.example.com' : 'economy',
'www.test.com' : 'test',
'test.com' : 'test'
}
),
)


Kenneth

Reply all
Reply to author
Forward
0 new messages