Attachment Improvements By Xon

xF2 Add-on Attachment Improvements By Xon 2.6.1

No permission to download
Q. Attachment eTags are showing up prefixed with "W/"
A. This is expected depending on the CDN/webserver configuration. This add-on implements a workaround to support this.

Cloudflare has been seen to prepend W/ to some eTags to transform them from a strong eTag to a weak eTag.

Q.Attachment Etags are no longer a quoted number like standard XenForo eTags
A. Make sure the internal_data path has (depending on exact nginx configuration):
Code:
add_header Etag $upstream_http_etag;
Q. After following Using DigitalOcean Spaces or Amazon S3 for file storage in XF 2.x attachments no longer show.

A. Additional configuration is required to enable X-Accel-Redirect when using DigitalOcean Spaces or Amazon S3

A `internalDataUrl` stanza l must be added to `config.php` like the `externalDataUrl` described in the tutorial

```php
$config['internalDataUrl'] = function($externalPath, $canonical)
{
return 'internal_data_s3/..../internal_data/' . $externalPath;
};
```
nginx config must be updated with a new `internal_data_s3` block;
```php
location ~* /internal_data_s3/(.*?)://(.*?)/(.*) {
internal;
set $xfEtag $upstream_http_etag;
set $download_protocol $1;
set $download_host $2;
set $download_path $3;
set $download_url $download_protocol://$download_host/$download_path;

resolver 127.0.0.1 ipv6=off;
proxy_set_header Host $download_host;
proxy_set_header Authorization '';
proxy_set_header Cookie '';
proxy_max_temp_file_size 0;
proxy_intercept_errors on;
error_page 301 302 307 = @handle_redirect;

proxy_pass $download_url$is_args$args;

proxy_hide_header Content-Disposition;
proxy_hide_header Content-Type;
proxy_hide_header Etag;
proxy_hide_header x-amz-request-id;

add_header Etag $xfEtag;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
}

location @handle_redirect {
resolver 127.0.0.1 ipv6=off;
set $saved_redirect_location '$upstream_http_location';
proxy_pass $saved_redirect_location;
}
```

To implement proxy caching see https://www.nginx.com/resources/wiki/start/topics/examples/reverseproxycachingexample/
Top