Flask 应用程序正在AH01630:客户端因 Apache 中的服务器配置错误而被拒绝



尝试向我的 Flask 应用程序发送请求时获取 403 禁止。

在网上找到了很多此错误的例子,但到目前为止,没有一个解决方案对我有用。

来自 apache 错误日志文件的错误:

AH01630: client denied by server configuration: /opt/MyTinyURL/webtool.wsgi

这是我的虚拟主机。

<VirtualHost *:80>
  ServerName MY_SERVER_NAME
  DocumentRoot /opt/MyTinyURL
  WSGIDaemonProcess webtool user=www-data group=www-data threads=5 home=/opt/MyTinyURL/
  WSGIScriptAlias / "/opt/MyTinyURL/webtool.wsgi"
  <Directory "/opt/MyTinyUrl">
    Options Indexes FollowSymLinks MultiViews ExecCGI
    AllowOverride None
    Require all granted
    WSGIProcessGroup webtool
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptReloading On
  </Directory>
</VirtualHost>

UNIX 文件路径名区分大小写。与WSGIScriptAlias一起使用的路径与 Directory 指令中使用的路径不匹配。

清理一些不需要的东西的其他问题,请尝试使用:

<VirtualHost *:80>
  ServerName MY_SERVER_NAME
  # XXX Bad practice to set DocumentRoot to be directory
  # where your code is. Comment out WSGIScriptAlias and
  # people could download your source code.
  # DocumentRoot /opt/MyTinyURL
  # XXX Don't need user/group as the default to Apache user.
  WSGIDaemonProcess webtool threads=5 home=/opt/MyTinyURL/
  WSGIScriptAlias / "/opt/MyTinyURL/webtool.wsgi"
  # XXX You had MyTinyUrl and not MyTinyURL.
  <Directory "/opt/MyTinyURL">
    Options Indexes FollowSymLinks MultiViews ExecCGI
    AllowOverride None
    Require all granted
    WSGIProcessGroup webtool
    WSGIApplicationGroup %{GLOBAL}
    # XXX Script reloading is the default option.
    # WSGIScriptReloading On
  </Directory>
</VirtualHost>

最新更新