Hello :)
I am experiencing an issue when I try to log-in through http, then
through https behind Apache using WSGI.
Web2py Version 2.9.5-stable+timestamp.2014.03.16.02.35.39
Python 2.7.3: /usr/bin/python (prefix: /usr)
Traceback (most recent call last):
File "/opt/web2py/gluon/main.py", line 457, in wsgibase
session._try_store_in_db(request, response)
File "/opt/web2py/gluon/globals.py", line 1089, in _try_store_in_db
(self._unchanged(response) and not response.session_new)):
File "/opt/web2py/gluon/globals.py", line 1078, in _unchanged
session_pickled = cPickle.dumps(self)
File "/usr/lib/python2.7/copy_reg.py", line 84, in _reduce_ex
dict = getstate()
TypeError: 'NoneType' object is not callable
After apache restart it works fine.
Seems to be related to these:
https://code.google.com/p/web2py/issues/detail?id=1438#makechanges
https://groups.google.com/forum/#!topic/web2py/jkqyPM5_zaE
https://groups.google.com/forum/#!msg/web2py/2SLPllKa-qQ/E_a55n5iGTMJ
My setup is:
1. One WSGIDaemonProcess for the whole apache server:
WSGIDaemonProcess web2py user=www-data group=www-data display-name=%{GROUP}
2. SSL config for the whole server - mainly for the purpose of accessing
web2py admin interface:
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/self_signed.cert
SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key
WSGIProcessGroup web2py
WSGIScriptAlias / /opt/web2py/wsgihandler.py
<Directory /opt/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*)
/opt/web2py/applications/$1/static/$2
<Directory /opt/web2py/applications/*/static/>
Order Allow,Deny
Allow from all
</Directory>
CustomLog /var/log/apache2/access-ssl.log common
ErrorLog /var/log/apache2/error-ssl.log
</VirtualHost>
3. Macro:
<Macro Web2Py $domain>
ServerName $domain
WSGIProcessGroup web2py
WSGIScriptAlias / /opt/web2py/wsgihandler.py
<Directory /opt/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*)
/opt/web2py/applications/$1/static/$2
<Directory /opt/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/$domain.log common
ErrorLog /var/log/apache2/$domain-error.log
</Macro>
4. Virtual hosts (in separate files):
# firstdomain.com
<VirtualHost *:80>
ServerName firstdomain.com
RedirectMatch permanent (.*) http://www.firstdomain.com$1
</VirtualHost>
<VirtualHost *:80>
Use Web2Py www.firstdomain.com
</VirtualHost>
# my.mywebserver.com
<VirtualHost *:80>
Use Web2Py my.mywebserver.com
</VirtualHost>
4. Routes in web2py:
routers = dict(
BASE=dict(
domains = {
'www.firstdomain.com' : 'firstapp',
'my.mywebserver.com' : 'myapp',
}
),
)
A workaround is suggested at the end of the thread:
https://groups.google.com/forum/#!topic/web2py/jkqyPM5_zaE
"Anyway i use different WSGIDaemonProcess on https and http and problem
solve."
So, I have changed in Macro:
WSGIProcessGroup web2py
to
WSGIDaemonProcess $domain user=www-data group=www-data display-name=%{GROUP}
WSGIProcessGroup $domain
and the problem seems to be solved. But is it really correct to use
different WSGIDaemonProcess for the same web2py instance?
Graham Dumpleton here:
https://groups.google.com/forum/#!topic/modwsgi/URpyQXl5d8g
lists several potential problems related to a configuration with
separate WSGIDaemonProcess, such as leakage of data between sub
interpreters. He suggests:
"Overall, the safest thing to do is to have each distinct web
application instance delegated to its own daemon process group, with
it being forced to run in %{GLOBAL} application group of that daemon
process group. The %{GLOBAL} here means force it to run in the main
(first created) Python interpreter within the process. This is
equivalent to the interpreter environment which is used by command
line Python and so all C extension modules should work in that."
Please, is there anyone with the necessary inside to provide correct
instructions how to set-up multiple virtual hosts with SSL, all served
by one web2py instance behind Apache correctly? It would be great to
include the instructions in the web2py book, because IMO such config is
likely to be quite common. :)
Thanks in advance!
David
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.