You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is much faster than Magento's built-in sync, because `aws s3 sync` uploads files concurrently.
85
+
In any case, that is much faster than Magento's built-in sync, because `aws s3 sync` uploads files concurrently.
66
86
67
87
## The storage flag file in the bucket
68
88
69
89
Magento's S3 implementation creates a test file called `storage.flag`, which is basically created to test if the connection works. So this is not a magic file to mark anything ([source](https://github.com/magento/magento2/blob/6f4805f82bb7511f72935daa493d48ebda3d9039/app/code/Magento/AwsS3/Driver/AwsS3.php#L104)).
70
90
71
91
## Serving assets from your S3 bucket
72
92
73
-
To start serving media assets from your S3 bucket, you need to make some adjustments to your nginx configuration. Create the following file at `/data/web/nginx/example.com/server.assets.conf` for each relevant vhost:
74
-
75
-
```nginx
76
-
set $backend "haproxy";
77
-
78
-
location @object_storage_fallback {
79
-
# Proxy to object storage
80
-
set $bucket "my_bucket_name";
81
-
proxy_cache_key "$bucket$uri";
82
-
proxy_cache_valid 200 302 7d;
83
-
proxy_cache_methods GET HEAD;
84
-
proxy_cache_background_update on;
85
-
proxy_cache_use_stale updating;
86
-
proxy_cache asset_cache;
87
-
resolver 8.8.8.8;
88
-
proxy_pass https://$bucket.s3.amazonaws.com$uri;
89
-
proxy_pass_request_body off;
90
-
proxy_pass_request_headers off;
91
-
proxy_intercept_errors on;
92
-
proxy_hide_header "x-amz-id-2";
93
-
proxy_hide_header "x-amz-request-id";
94
-
proxy_hide_header "x-amz-storage-class";
95
-
proxy_hide_header "x-amz-server-side-encryption";
96
-
proxy_hide_header "Set-Cookie";
97
-
proxy_ignore_headers "Set-Cookie";
98
-
add_header Cache-Control "public";
99
-
add_header X-Frame-Options "SAMEORIGIN";
100
-
add_header X-Cache-Status $upstream_cache_status;
101
-
expires +1y;
102
-
103
-
# If object storage fails, fallback to PHP handler
To start serving media assets from your S3 bucket, you need to make some adjustments to your nginx configuration. Luckily, `hypernode-manage-vhosts` does this for you! If you are using Hypernode's object storage solution, all you need to do is run the following for relevant vhosts:
124
94
125
-
location ~ ^/static/ {
126
-
expires max;
127
-
128
-
# Remove signature of the static files that is used to overcome the browser cache
If you have previously set your own custom bucket name and URL, but have since switched to Hypernode's object storage solution, then you can use the `--object-storage-defaults` flag to force overwrite your values to Hypernode's default ones:
Make sure to change the string `my_bucket_name` to the name of your bucket and keep in mind that your bucket URL might be different depending on your AWS region. For example, you might need to change it from `https://$bucket.s3.amazonaws.com$uri` to `https://s3.amazonaws.com/$bucket$uri` instead.
175
-
Furthermore, ensure that your S3 bucket policies are configured correctly, so that only `/media` is publicly readable. For example:
110
+
Furthermore, if you're using Amazon S3 as your bucket, ensure that your S3 bucket policies are configured correctly, so that only `/media` is publicly readable. For example:
0 commit comments