Routes for 2 domains and 2 apps

45 views
Skip to first unread message

Jean-François Milants

unread,
Jan 17, 2015, 1:05:16 PM1/17/15
to web...@googlegroups.com
Hi,

I currently have a web2py app running on my server. Lets call it App1. I created a VirtualHost for my Apache so that 'domain1' points to this app. This app supports 2 languages (fr and en). I already have a certificate for this domain, so, it is running in HTTPS.

Now, I want to add a second web2py app ('App2'), with another domain ('domain2') pointed to it.

So, I have 2 VirtualHosts, one for domain1 and one for domain2:

WSGIDaemonProcess web2py user=www-data group=www-data display-name=%{GROUP}

<VirtualHost *:443>
              ServerName domain1
        ServerAlias domain1

        WSGIProcessGroup web2py
        WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py

        ....
</VirtualHost>

<VirtualHost *:80>
        ServerName domain2
        ServerAlias domain2

        WSGIProcessGroup web2py
        WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py

        ...
</VirtualHost>

In routes.py:
routers = dict(
  BASE  = dict(
        domains= {
                'domain1' : 'App1',
                'domain2' : 'App2',
        }
  ),

  App1 = dict(languages=['en', 'fr'], default_language='fr'),
)


With these settings, I cannot manage to have the 2 applications running at the same time time : only the first App I visit will run correctly, the other one returns an error 500, with this traceback:
Traceback (most recent call last):
File "/home/www-data/web2py/gluon/main.py", line 435, in wsgibase
session.connect(request, response)
File "/home/www-data/web2py/gluon/globals.py", line 931, in connect
session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
TypeError: 'NoneType' object is not callable

I can provide the full error ticket if needed.

It seems there is an error with session. I try to clean both apps with no luck.
Note that I had to rename App2 (it had another name before). I simply renamed the directory of App2. I don't know if it's causing my issue...

Any help?

Thanks!


c...@cemeren.com

unread,
Jan 19, 2015, 4:18:18 PM1/19/15
to web...@googlegroups.com
Hi,

Try to use separate wsgi processes for each ssl site.

Please see my example below. 

one process for all non ssl sites and separate process for each ssl site.

<VirtualHost *:80>
DocumentRoot /var/sites/web2py

WSGIDaemonProcess web2py user=www-data group=www-data \
                           display-name=%{GROUP}
  WSGIProcessGroup web2py
  WSGIScriptAlias / /var/sites/web2py/web2py/wsgihandler.py

  <Directory /var/sites/web2py/web2py>
    Require all denied
    <Files wsgihandler.py>
      Require all granted
    </Files>
  </Directory>

  <Directory /var/sites/web2py/web2py/applications/*/static/>
    Require all granted
  </Directory>

  <Location /admin>
    Require all denied
  </Location>

  <LocationMatch ^/([^/]+)/appadmin>
  Require all denied
  </LocationMatch>
ServerAlias list_of_domains
</VirtualHost>


<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/domain.crt
  SSLCertificateKeyFile /etc/apache2/ssl/domain.key
  SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem
  SSLCACertificateFile /etc/apache2/ssl/ca.pem

DocumentRoot /var/sites/web2py
ServerName domain_with_ssl

WSGIDaemonProcess domainssl user=www-data group=www-data \
                           display-name=%{GROUP}
  WSGIProcessGroup domainssl
  WSGIScriptAlias / /var/sites/web2py/web2py/wsgihandler.py

  <Directory /var/sites/web2py/web2py>
    Require all denied
    <Files wsgihandler.py>
      Require all granted
    </Files>
  </Directory>

  <Directory /var/sites/web2py/web2py/applications/*/static/>
    Require all granted
  </Directory>

  <Location /admin>
    Require ip 127.0.0.1
  </Location>

  <LocationMatch ^/([^/]+)/appadmin>
    Require ip 127.0.0.1
  </LocationMatch>
ServerAlias domainssl
</VirtualHost>
Reply all
Reply to author
Forward
0 new messages