【问题标题】:WSGIScriptAlias overrides AliasWSGIScriptAlias 覆盖别名
【发布时间】:2014-06-16 02:36:32
【问题描述】:

我在使用 Apache 2.2 配置 mod_wsgi 时遇到问题。我需要 mod_wsgi 来处理虚拟服务器根目录下的所有内容,除了某些路径。对于那些路径,我希望普通的 Apache 目录列表能够正常工作。以下虚拟服务器配置一半有效。 mod_wsgi 不会直接用于文件的路径,但会用于目录。我想不通。在这里查看文档 - https://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide。它以我必须禁用 mod_wsgi 的方式显示使用别名,但未提及此问题。 (请注意,这并不重要,但 foo.wsgi 端点只是 hello world 示例)。

<VirtualHost *:80>
    ServerAdmin webmaster@test.wsgi.sethandler.localdomain
    ServerName test.wsgi.sethandler.localdomain
  DocumentRoot /var/www/test.wsgi.sethandler.localdomain

    <Directory /var/www/test.wsgi.sethandler.localdomain>
        Options Indexes FollowSymLinks MultiViews 
        AllowOverride FileInfo Options Indexes
        Order allow,deny
        allow from all
    </Directory>

  Alias /static /var/www/test.wsgi.sethandler.localdomain/static

  WSGIScriptAlias / /var/www/test.wsgi.sethandler.localdomain/cgi-bin/foo.wsgi

  <Directory /var/www/test.wsgi.sethandler.localdomain/cgi-bin>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
  </Directory>
</VirtualHost>

我尝试使用以下方法禁用任何处理程序,但它不起作用:

<Location "/static">
  SetHandler None
</Location>

<LocationMatch ^/static>
  SetHandler None
</LocationMatch>

【问题讨论】:

    标签: python wsgi


    【解决方案1】:

    你有没有尝试在静态之后放置和结束斜线?

    Alias /static/ /var/www/test.wsgi.sethandler.localdomain/static/
    
    <Directory /var/www/test.wsgi.sethandler.localdomain/static/>
    Require all granted
    </Directory>
    
    WSGIScriptAlias / /var/www/test.wsgi.sethandler.localdomain/cgi-bin/foo.wsgi
    

    【讨论】:

    • 是的,我试过了。它不应该有任何不同,除了 1. 您应该在别名和目标上使用尾部斜杠或从两者中省略它以及 2. 在别名上使用尾部斜杠不会匹配说 "/static" only "/static/" -带有斜杠。参考httpd.apache.org/docs/2.2/mod/mod_alias.html#aliasRequire all granted 也没有提供任何帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-19
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多