Skip to content

Commit 862ddf7

Browse files
dominik-matichrithikkothari1234
authored andcommitted
update magento2 s3 obj storage doc
1 parent 88e5678 commit 862ddf7

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

docs/ecommerce-applications/magento-2/how-to-configure-remote-storage-for-magento-2-x.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,43 @@ Magento's S3 implementation creates a test file called `storage.flag`, which is
7272

7373
To start serving media assets from your S3 bucket, you need to make some adjustments to your nginx configuration.
7474

75+
We recommend that you create a configuration file defining the cache storage location, structure, size constraints, and cache expiration policies.
76+
```bash
77+
echo "proxy_cache_path /data/var/nginx-asset-cache levels=1:2 keys_zone=asset_cache:10m max_size=1g inactive=1w;" > /data/web/nginx/http.asset_proxy_cache.conf
78+
```
79+
80+
Then update your nginx configuration in the following manner.
81+
7582
```nginx
7683
location /media {
7784
# ...
7885
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
7986
resolver 8.8.8.8;
8087
set $bucket "<my_bucket_name>";
81-
proxy_pass https://s3.amazonaws.com/$bucket$uri;
88+
proxy_pass https://$bucket.s3.amazonaws.com$uri;
8289
proxy_pass_request_body off;
8390
proxy_pass_request_headers off;
8491
proxy_intercept_errors on;
8592
proxy_hide_header "x-amz-id-2";
8693
proxy_hide_header "x-amz-request-id";
8794
proxy_hide_header "x-amz-storage-class";
95+
proxy_hide_header "x-amz-server-side-encryption";
8896
proxy_hide_header "Set-Cookie";
8997
proxy_ignore_headers "Set-Cookie";
98+
99+
# only include the following if you followed the previous step
100+
proxy_cache_key "$bucket$uri";
101+
proxy_cache_valid 200 302 7d;
102+
proxy_cache_methods GET HEAD;
103+
proxy_cache_background_update on;
104+
proxy_cache_use_stale updating;
105+
proxy_cache asset_cache;
106+
90107
}
91108
# ...
92109
}
93110
```
94-
111+
Keep in mind your bucket URL might be different depending on your AWS region. For example, you might need to change it to `https://s3.amazonaws.com/$bucket$uri` instead.
95112
Also make sure your S3 bucket policies are configured correctly, so that only `/media` is publicly readable. For example:
96113

97114
```json

0 commit comments

Comments
 (0)