我有一台使用 apache2 和 redmine 配置了 redmine 的服务器。配置相对简单:
<VirtualHost localhost>
RailsEnv production
# create a link in /var/lib/redmine/default/passenger to /usr/share/redmine
PassengerAppRoot /var/lib/redmine/default/passenger
SetEnv X_DEBIAN_SITEID "default"
Alias "/plugin_assets/" /var/cache/redmine/default/plugin_assets/
DocumentRoot /usr/share/redmine/public
<Directory "/usr/share/redmine/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
现在我想有一个包含静态文件的子目录 /downloads。所以我稍微修改了配置
<VirtualHost localhost>
RailsEnv production
# create a link in /var/lib/redmine/default/passenger to /usr/share/redmine
PassengerAppRoot /var/lib/redmine/default/passenger
SetEnv X_DEBIAN_SITEID "default"
Alias "/plugin_assets/" /var/cache/redmine/default/plugin_assets/
DocumentRoot /usr/share/redmine/public
<Directory "/usr/share/redmine/public">
Order allow,deny
Allow from all
</Directory>
Alias "/downloads/" /srv/downloads/
<Directory "/srv/downloads/">
Order allow,deny
Allow from all
Options +Indexes
</Directory>
</VirtualHost>
在没有安装 Passenger 的情况下,这个功能可以正常工作,但使用 Passenger 时则不行。有趣的是,
localhost/downloads/test.gif
工作正常,但不是请求localhost/downloads/
(应该显示目录列表......但却查询 redmine)
是否可能仍然获得可浏览的 mod_autoindex 子目录?
答案1
还需要添加一个使乘客无法行动的位置。
<VirtualHost localhost>
RailsEnv production
# create a link in /var/lib/redmine/default/passenger to /usr/share/redmine
PassengerAppRoot /var/lib/redmine/default/passenger
SetEnv X_DEBIAN_SITEID "default"
Alias "/plugin_assets/" /var/cache/redmine/default/plugin_assets/
DocumentRoot /usr/share/redmine/public
<Directory "/usr/share/redmine/public">
Order allow,deny
Allow from all
</Directory>
Alias "/downloads/" /srv/downloads/
<Directory "/srv/downloads/">
Order allow,deny
Allow from all
Options +Indexes
</Directory>
<Location /downloads/>
PassengerEnabled off
</Location>
</VirtualHost>
或者更好的解决方案:默认禁用它并仅为 webapp 启用它
<VirtualHost localhost>
PassengerEnabled off
RailsEnv production
# create a link in /var/lib/redmine/default/passenger to /usr/share/redmine
PassengerAppRoot /var/lib/redmine/default/passenger
SetEnv X_DEBIAN_SITEID "default"
Alias "/plugin_assets/" /var/cache/redmine/default/plugin_assets/
DocumentRoot /usr/share/redmine/public
<Directory "/usr/share/redmine/public">
PassengerEnabled on
Order allow,deny
Allow from all
</Directory>
Alias "/downloads" /srv/downloads
<Directory "/srv/downloads">
Order allow,deny
Allow from all
Options +Indexes
</Directory>
</VirtualHost>