-
Notifications
You must be signed in to change notification settings - Fork 36
docs: Horizontal autoscaling improvements #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
edb4f5b
docs: Add Magento 2 Remote Storage documentation
tdgroot 48f7dbc
docs/autoscaling: Link to remote storage
tdgroot f7d5123
docs/autoscaling: Polish up little details
tdgroot d3817d5
docs/rabbitmq: Add nodes on creating users better magento2 config
tdgroot 2cda8c0
bin/watch: Use cross-platform watchdog
tdgroot 7d216b6
chore: mdformat and black
tdgroot 631afe8
docs/autoscaling: Fix incorrect console prompt hostnames
tdgroot 2bddc86
bin/watch: Add debounce for batched events
tdgroot 6834703
docs/magento2: Add serving assets example
tdgroot a03b61e
docs/autoscaling: Add more clarification on requirements
tdgroot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
...merce-applications/magento-2/how-to-configure-remote-storage-for-magento-2-x.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| --- | ||
| myst: | ||
| html_meta: | ||
| description: Configure remote storage for Magento 2.x. Learn how to configure | ||
| Magento 2 to start storing files in your bucket using a single command. | ||
| title: How to Configure Remote Storage for Magento 2.x | Hypernode | ||
| --- | ||
|
|
||
| # How to Configure Remote Storage for Magento 2.x | ||
|
|
||
| Magento 2.x supports remote storage for media files, import/export files, and other files. | ||
| This feature allows you to store files in a remote storage location, such as an Amazon S3 bucket, instead of storing them on the server itself. | ||
|
|
||
| This can be useful for many reasons, such as: | ||
|
|
||
| - Offloading storage from your server, reducing the load on your server, and improving performance. | ||
| - Allows you to make use of [horizontal scaling](../../hypernode-platform/autoscaling/how-does-horizontal-autoscaling-work), as you can easily add more servers without having to worry about syncing files between them. | ||
| - Allows for effortless storage capacity scaling, as you can easily increase the storage capacity of your remote storage location. | ||
| - Serving assets from a CDN, which can improve the performance of your website. | ||
|
|
||
| ## Configuring the application | ||
|
|
||
| Configuring Magento 2 to start storing files in your bucket is done using a single command. | ||
|
|
||
| **AWS S3** | ||
|
|
||
| ```bash | ||
| bin/magento setup:config:set \ | ||
| --remote-storage-driver="aws-s3" \ | ||
| --remote-storage-bucket="my_bucket_name" \ | ||
| --remote-storage-region="my-aws-region" \ | ||
| --remote-storage-key="abcd1234" \ | ||
| --remote-storage-secret="abcd1234" | ||
| ``` | ||
|
|
||
| **Other S3 compatible providers** | ||
|
|
||
| If you're using a different provider than AWS S3, you need to specify the `--remote-storage-endpoint` option. | ||
|
|
||
| ```bash | ||
| bin/magento setup:config:set \ | ||
| --remote-storage-driver="aws-s3" \ | ||
| --remote-storage-bucket="my_bucket_name" \ | ||
| --remote-storage-region="provider-region" \ | ||
| --remote-storage-key="abcd1234" \ | ||
| --remote-storage-secret="abcd1234" \ | ||
| --remote-storage-endpoint="https://my-s3-compatible.endpoint.com" | ||
| ``` | ||
|
|
||
| ## Syncing the files | ||
|
|
||
| Instead of running (which is Magento's official way to do this): | ||
|
|
||
| ```bash | ||
| bin/magento remote-storage:sync | ||
| ``` | ||
|
|
||
| One can run the following instead to really speed up the process: | ||
|
|
||
| ```bash | ||
| aws s3 sync pub/media/ s3://my_bucket_name/media/ | ||
| aws s3 sync var/import_export s3://my_bucket_name/import_export | ||
| ``` | ||
|
|
||
| This is much faster than Magento's built-in sync, because `aws s3 sync` uploads files concurrently. | ||
|
|
||
| ## The storage flag file in the bucket | ||
|
|
||
| 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)). | ||
|
|
||
| ## Serving assets from your S3 bucket | ||
|
|
||
| To start serving media assets from your S3 bucket, you need to make some adjustments to your nginx configuration. | ||
|
|
||
| ```nginx | ||
| location /media { | ||
| # ... | ||
| location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { | ||
| resolver 8.8.8.8; | ||
| set $bucket "<my_bucket_name>"; | ||
| proxy_pass https://s3.amazonaws.com/$bucket$uri; | ||
| proxy_pass_request_body off; | ||
| proxy_pass_request_headers off; | ||
| proxy_intercept_errors on; | ||
| proxy_hide_header "x-amz-id-2"; | ||
| proxy_hide_header "x-amz-request-id"; | ||
| proxy_hide_header "x-amz-storage-class"; | ||
| proxy_hide_header "Set-Cookie"; | ||
| proxy_ignore_headers "Set-Cookie"; | ||
| } | ||
| # ... | ||
| } | ||
| ``` | ||
|
|
||
| Also make sure your S3 bucket policies are configured correctly, so that only `/media` is publicly readable. For example: | ||
|
|
||
| ```json | ||
| { | ||
| "Version": "2012-10-17", | ||
| "Statement": [ | ||
| { | ||
| "Sid": "AllowPublicReadOnlyForMedia", | ||
| "Effect": "Allow", | ||
| "Principal": "*", | ||
| "Action": "s3:GetObject", | ||
| "Resource": "arn:aws:s3:::<your-bucket-name>/media/*" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ## Magento remote storage documentation | ||
|
|
||
| - [Configure Remote Storage](https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/storage/remote-storage/remote-storage) | ||
| - [Configure AWS S3 bucket for remote storage](https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/storage/remote-storage/remote-storage-aws-s3) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.