#12239 closed task (fixed)
Configure Apache to serve attachments
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Component: | TracHacks |
Severity: | normal | Keywords: | |
Cc: | osimons, Steffen Hoffmann, Michael Renzmann, Jun Omae | Trac Release: |
Description (last modified by )
The following are excerpts from an email discussion that took place after upgrading to Trac 1.0.
I previously mentioned the problem with attachments not having been migrated from the $TRACENV/attachments
directory to $TRACENV/files/attachments
. After re-running one of the database upgrade steps, the attachments were still not displaying, however from what I saw in the logs with the log level set to debug, it seemed like Trac was serving up the file, and there was something wrong with the Apache configuration. Further evidence was that Trac no longer displayed a TracError when attempting to navigate to an attachment, rather it displayed an image of a broken attachment link.
With Trac 1.0, the attachment, th:attachment/wiki/BookmarkPlugin/bookmarkpage.jpg
is now stored at,
$TRACENV/files/attachments/wiki/819/819ffdd855b12bca022d5a9f4e1b75ea2f91b067/4baf82047b92bfcc6bde2217dfc158ead669a4c2.jpg
So I started poking around at the Apache configuration, and seem to have it working with the following change:
-
trac-hacks-010
old new 27 27 Alias /chrome/common /path/to/www/htdocs/common 28 28 Alias /chrome/site /path/to/www/htdocs/site 29 29 Alias /errorpages /path/to/www/errorpages 30 Alias /raw-attachment /path/to/trac/attachments/30 # Alias /raw-attachment /path/to/trac/files/attachments/ 31 31 32 32 # use mod_rewrite to let Apache handle 0.10-style requests for 33 33 # raw attachments 34 34 RewriteEngine On 35 35 RewriteCond %{QUERY_STRING} ^format=raw$ 36 RewriteRule ^/attachment/(.*) /path/to/trac/ attachments/$1 [L]36 RewriteRule ^/attachment/(.*) /path/to/trac/files/attachments/$1 [L] 37 37 38 38 <Directory /path/to/www/htdocs> 39 39 Options -Indexes 40 40 Order allow,deny 41 41 Allow from all 42 42 </Directory> 43 <Directory /path/to/trac/ attachments>43 <Directory /path/to/trac/files/attachments> 44 44 Options -Indexes 45 45 Order allow,deny 46 46 Allow from all
This is a side-effect of the new storage scheme for attachments, and due to the cryptic naming, mapping them through apache is no longer an option. As far as I can tell there is no way we can keep any of the config rules that point to attachments on disk, and these should be removed.
I complained about this some time ago: trac:comment:25:ticket:10313
But since that time another good solution has been implemented instead: trac:#7894
So install & enable mod_xsendfile
seems to be the proper fix for this for Trac 1.0+.
Attachments (0)
Change History (3)
comment:1 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 10 years ago by
Cc: | osimons Steffen Hoffmann Michael Renzmann Jun Omae added |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:3 Changed 10 years ago by
Debian 8 has mod-sendfile 0.12 and Apache 2.4., so the following configuration is used:
XSendFile on XSendFilePath /path/to/trac/env/files/attachments
Debian 7 has mod-sendfile 0.9, so the following configuration is used:
We could use some brief Trac documentation on configuring
mod_xsendfile
. I'll add that soon.