简体   繁体   English

apache2 + mod_wsgi + U2F

[英]apache2 + mod_wsgi + U2F

mod_wsgi is pretty new for me. mod_wsgi对我来说很新。 I followed all steps of this doc ( https://developers.yubico.com/u2fval/Apache_Deployment.html ) but i stell get an error. 我遵循了该文档的所有步骤( https://developers.yubico.com/u2fval/Apache_Deployment.html ),但我却发现一个错误。

My Steps: 我的步骤:

  • sudo apt-get --assume-yes update sudo apt-get --assume-yes更新
  • sudo apt-get --assume-yes install build-essential libssl-dev libffi-dev python-dev python-virtualenv sudo apt-get --assess-yes install build-essential libssl-dev libffi-dev python-dev python-virtualenv
  • mkdir -p /etc/yubico/u2fval mkdir -p / etc / yubico / u2fval
  • cd /etc/yubico/u2fval cd / etc / yubico / u2fval
  • virtualenv venv 虚拟环境
  • source venv/bin/activate 来源venv / bin / activate
  • sudo pip install --upgrade setuptools pip sudo pip install --upgrade setuptools pip
  • sudo pip install u2fval sudo pip安装u2fval
  • sudo apt-get --assume-yes install apache2-utils libapache2-mod-wsgi sudo apt-get --assume-yes安装apache2-utils libapache2-mod-wsgi
  • a2enmod auth_digest a2enmod auth_digest
  • Create a file (u2fval.wsgi) at /etc/yubico/u2fval with the content: from u2fval import app as application / etc / yubico / u2fval中创建一个文件(u2fval.wsgi),内容如下: 从u2fval导入应用程序作为应用程序
  • Generate a file (u2fval.conf) at /etc/apache2/conf-available/ with following content: / etc / apache2 / conf-available /处生成具有以下内容的文件(u2fval.conf):
<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 a2enconf u2fval
  • service apache2 reload 服务apache2重新加载

If I try to open http://localhost/wsapi/u2fval/ I get this error: 如果我尝试打开http:// localhost / wsapi / u2fval /,则会出现此错误:

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: /var/log/apache2/error.log中表示:

[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. 我差点搜寻了三个小时,却没有找到解决方法。

If your application code is in /etc/yubico/u2fval , then add: 如果您的应用程序代码在/etc/yubico/u2fval ,请添加:

python-path=/etc/yubico/u2fval

to the WSGIDaemonProcess directive. WSGIDaemonProcess指令。

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. 您需要告诉它您的应用程序代码在哪里,因为它不会自动在WSGI脚本文件所在的目录中查找。

BTW, the path in the error message doesn't match what your configuration says is the location of your WSGI script file. 顺便说一句,错误消息中的路径与您的配置所说的是WSGI脚本文件的位置不匹配。 Anyway, adjust that path as necessary. 无论如何,请根据需要调整该路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM