0
votes

mod_wsgi is pretty new for me. I followed all steps of this doc (https://developers.yubico.com/u2fval/Apache_Deployment.html) but i stell get an error.

My Steps:

  • sudo apt-get --assume-yes update
  • sudo apt-get --assume-yes install build-essential libssl-dev libffi-dev python-dev python-virtualenv
  • mkdir -p /etc/yubico/u2fval
  • cd /etc/yubico/u2fval
  • virtualenv venv
  • source venv/bin/activate
  • sudo pip install --upgrade setuptools pip
  • sudo pip install u2fval
  • sudo apt-get --assume-yes install apache2-utils libapache2-mod-wsgi
  • a2enmod auth_digest
  • Create a file (u2fval.wsgi) at /etc/yubico/u2fval with the content: from u2fval import app as application
  • Generate a file (u2fval.conf) at /etc/apache2/conf-available/ with following content:
<IfModule mod_wsgi.c>
        WSGIDaemonProcess u2fval python-home=/etc/yubico/u2fval/venv
        WSGIApplicationGroup %{GLOBAL}

        WSGIScriptAlias /wsapi/u2fval /etc/yubico/u2fval/u2fval.wsgi process-group=u2fval

        <Directory /etc/yubico/u2fval>
                Options None
                AllowOverride None
                AuthType Digest
                AuthName "u2fval"
                AuthUserFile /etc/yubico/u2fval/clients.htdigest
                Require valid-user
        </Directory>
</IfModule>
  • a2enconf u2fval
  • service apache2 reload

If I try to open http://localhost/wsapi/u2fval/ I get this error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

In /var/log/apache2/error.log stands:

[Wed Mar 28 09:34:22.915421 2018] [mpm_prefork:notice] [pid 31834] AH00163: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Wed Mar 28 09:34:22.915487 2018] [core:notice] [pid 31834] AH00094: Command line: '/usr/sbin/apache2'
[Wed Mar 28 09:34:39.052131 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] mod_wsgi (pid=31916): Target WSGI script '/etc/yubico/u2fval/u2fval.wsgi' cannot be loaded as Python module.
[Wed Mar 28 09:34:39.052197 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] mod_wsgi (pid=31916): Exception occurred processing WSGI script '/etc/yubico/u2fval/u2fval.wsgi'.
[Wed Mar 28 09:34:39.052514 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] Traceback (most recent call last):
[Wed Mar 28 09:34:39.052563 2018] [:error] [pid 31916] [remote 192.168.198.13:49242]   File "/etc/yubico/u2fval/u2fval.wsgi", line 1, in <module>
[Wed Mar 28 09:34:39.052658 2018] [:error] [pid 31916] [remote 192.168.198.13:49242]     from u2fval import app as application
[Wed Mar 28 09:34:39.052687 2018] [:error] [pid 31916] [remote 192.168.198.13:49242] ImportError: No module named u2fval

Can anyone help me? I nearly searched for three hours and found no solution.

1

1 Answers

0
votes

If your application code is in /etc/yubico/u2fval, then add:

python-path=/etc/yubico/u2fval

to the WSGIDaemonProcess directive.

You need to tell it where your application code is, as it will not automatically look in the directory where the WSGI script file is.

BTW, the path in the error message doesn't match what your configuration says is the location of your WSGI script file. Anyway, adjust that path as necessary.