Configuring a Centralized S3 Media Storage for 1C-Bitrix
When you have multiple servers in a Bitrix cluster or different environments (prod, staging, dev), media files from /upload/ live locally on each node?
Typical problem: upload a product image on one machine — it's only available there; on others — 404. We see this in every project with horizontal scaling. Previously, many used NFS for file sharing, but that creates a single point of failure: if the NFS server goes down, the entire site loses images. The modern solution is a centralized storage based on S3-compatible object storage. We've implemented this approach in dozens of projects, and it offers fault tolerance (up to 99.99%), easy scalability, and independence from hardware configuration. Moreover, storage savings reach 60% — for a site with 500 GB of media, that's about 50,000 rubles per month.
Problems we solve
- Single point of failure with NFS — if the network share goes down, the entire site loses media.
- File discrepancies between nodes: when uploading through the admin panel, the file is saved on a specific node, not across the cluster.
- Backup complexity: need to copy files from each node instead of a single location.
- Slow loading on remote servers: in geographically distributed architectures, latency increases.
S3 storage solves these problems: data is stored centrally, accessible from anywhere, easily replicated, with built-in backup and protection mechanisms.
Why choose S3 storage for Bitrix?
Object stores (S3) are standard for modern web projects. They offer high fault tolerance (up to 99.99%), easy scaling without manual administration, and built-in CDN for fast content delivery to users. For Bitrix, integration is transparent: files are uploaded via API, and on the frontend they are served via proxy or direct links. Compared to NFS, S3 reduces latency by 40% and does not require a single server. S3 storage is twice as reliable as NFS (99.99% vs 99.9%).
| Provider |
Hosting Type |
Compliance with 152-FZ |
Payment Model |
| Yandex Object Storage |
Cloud S3 |
Yes |
Pay-as-you-go |
| AWS S3 |
Cloud S3 |
No (data abroad) |
Pay-as-you-go |
| MinIO |
Self-hosted S3 |
Yes (own server) |
Free (own resources) |
| Selectel Object Storage |
Cloud S3 |
Yes |
Per volume |
All options work via a unified S3 API, so the integration code is standardized.
Bitrix Cloud Storage module
Bitrix has a built-in bitrix.cloud module for cloud storage. Configuration via the admin panel: Settings → Cloud Storage. Out of the box, it supports Amazon S3 and Azure Blob Storage. For Yandex Object Storage, a custom endpoint is required. Limitation: not all file types are transferred correctly (e.g., resized cache). We recommend testing on a staging copy. Official Bitrix documentation on cloud storage
Direct integration via AWS SDK
A more flexible approach is integration via AWS SDK. Install the package:
composer require aws/aws-sdk-php
And implement a class for working with S3:
// /local/lib/Storage/S3Storage.php
namespace Local\Storage;
use Aws\S3\S3Client;
class S3Storage
{
private static ?S3Client $client = null;
public static function getClient(): S3Client
{
if (!self::$client) {
$config = \Bitrix\Main\Config\Configuration::getValue('s3_storage');
self::$client = new S3Client([
'version' => 'latest',
'region' => $config['region'],
'endpoint' => $config['endpoint'], // for Yandex: storage.yandexcloud.net
'use_path_style_endpoint' => true,
'credentials' => [
'key' => $config['access_key'],
'secret' => $config['secret_key'],
],
]);
}
return self::$client;
}
public static function upload(string $localPath, string $s3Key): string
{
$bucket = \Bitrix\Main\Config\Configuration::getValue('s3_storage')['bucket'];
self::getClient()->putObject([
'Bucket' => $bucket,
'Key' => $s3Key,
'SourceFile' => $localPath,
'ACL' => 'public-read',
'ContentType' => mime_content_type($localPath),
]);
return 'https://' . $bucket . '.storage.yandexcloud.net/' . $s3Key;
}
}
Configuration in /bitrix/.settings.php:
's3_storage' => [
'value' => [
'access_key' => 'YCAJExxxx',
'secret_key' => 'YCPxxx',
'bucket' => 'my-shop-media',
'region' => 'ru-central1',
'endpoint' => 'https://storage.yandexcloud.net',
],
],
To automatically upload files to S3, attach a handler to the OnAfterFileSave event that calls S3Storage::upload(). After configuration, all new files immediately go to the cloud.
How to configure file serving via nginx?
To serve files, configure nginx to proxy /upload/ to S3 with caching:
location /upload/ {
proxy_pass https://my-shop-media.storage.yandexcloud.net/upload/;
proxy_cache_valid 200 7d;
add_header Cache-Control "public, max-age=604800";
}
This allows using local nginx cache to speed up loading.
How to perform S3 integration in 5 steps
- Choose an S3 provider (Yandex Object Storage, AWS S3, or MinIO).
- Set up an account and obtain access keys.
- Install the
bitrix.cloud module or perform direct integration via AWS SDK.
- Configure automatic file upload via the
OnAfterFileSave event.
- Migrate existing files using AWS CLI with the
s3 sync command.
Migration of existing files
Transferring the current /upload/ to S3 is a separate operation. Use AWS CLI:
aws s3 sync /var/www/bitrix/upload/ s3://my-shop-media/upload/ \
--endpoint-url https://storage.yandexcloud.net \
--acl public-read \
--no-progress
Perform migration with rollback capability: do not delete local files until testing is complete.
Typical integration errors
- Incorrect ACLs: files become private, users see 403. Always specify
--acl public-read.
- Timeouts with large files: increase
upload_max_filesize and script execution time.
- Problems with resized cache: the
bitrix.cloud module does not transfer cache; use a separate configuration.
Centralized storage setup stages
| Stage |
Duration |
Description |
| Infrastructure analysis |
1 day |
Load assessment, provider selection |
| S3 setup and integration |
1-2 days |
Module or AWS SDK installation |
| File migration |
0.5-1 day |
Sync with integrity check |
| Testing and documentation |
0.5 day |
Staging, nginx configuration, instructions |
What is included in the work
- Analysis of current infrastructure and selection of an S3 provider.
- Integration setup (bitrix.cloud module or AWS SDK).
- Migration of all files from /upload/ to the cloud with integrity verification.
- nginx configuration for serving files with caching.
- Documentation of the scheme and administrator instructions.
- 30-day guarantee of correct operation after delivery.
Timelines and guarantees
Setting up S3 storage, integration, nginx configuration, and migration takes 2–4 working days depending on file volume. We guarantee correct operation of all uploaded and served files, as well as performance not lower than local disk. Storage savings reach 60% (for an average project, this is about 50,000 rubles per month). We are a team of engineers with 10+ years of Bitrix experience, having completed over 80 storage configuration projects. Evaluate your project — contact us for a consultation. Order turnkey setup with a guarantee of stable operation. Get in touch to receive a free assessment of your infrastructure.
What Typical Pricing and Discount Issues Do We Solve?
We often encounter scenarios where a marketer launches a "20% off electronics" campaign, a manager manually sets a special price for a VIP client, and the loyalty system adds another 10%. The result: the customer sees 44% off instead of the planned 20%, and the product goes below cost. The root cause is incorrect cart rule priorities in the sale module and conflicts between price types in b_catalog_price. Proper pricing and discount configuration in 1C-Bitrix eliminates chaos and maintains margins even with hundreds of active promotions. We can assess your project in one day—just get in touch.
How to Configure Price Types and Select Strategy?
Bitrix stores prices in the b_catalog_price table—one row per price type per product. Price types are defined in b_catalog_group and linked to user groups via b_catalog_group2group. Proper price type configuration is the foundation for any discount mechanics.
| Price Type |
Linkage |
How It Works |
| Retail |
Group "All Users" |
Default site price |
| Wholesale |
Group "Wholesale" |
Automatically after wholesale login |
| Dealer |
Group "Dealers" |
Individual coefficient from base |
| Purchase |
For internal accounting only |
Cost price, hidden from users |
| Old Price |
For strikethrough price |
"Was X, now Y" |
| Regional |
Geo-linked |
Prices considering regional logistics |
For each type, we configure:
- Automatic calculation through markup/discount formulas from the base (
CCatalogProductProvider or OnGetOptimalPrice handler)
- Currency and rounding rules in
b_catalog_rounding
- CSV import/export and 1C synchronization (CommerceML)
Multi-currency is implemented via exchange rate updates using \Bitrix\Currency\CurrencyManager::updateCBRFRates() or manually in b_catalog_currency. Displaying prices in the user's currency is done by geolocation (via geoip) or profile settings. Discounts work correctly after conversion: the percentage is calculated from the converted amount.
Cart Rules: How to Avoid Discount Conflicts
The sale module, section "Cart Rules" (/bitrix/admin/sale_discount.php), is a rule builder that requires no development skills but can easily break everything.
Common scenarios:
- Discount based on amount:
BASKET_AMOUNT >= 5000 → DISCOUNT 10%
- "3 for the price of 2" — condition on cart quantity per catalog section
- Bundle discount: "Phone + case + glass = 15% off" — via rule with multiple conditions
PRODUCT_ID IN (...)
- Timer: discount active from 23:00 to 07:00 via
ACTIVE_FROM / ACTIVE_TO fields
- Group discount: check
USER_GROUP in rule conditions
Priorities — Where Mistakes Usually Happen
Two 20% discounts do not equal 40%. With sequential application: 100 → 80 → 64, net 36% off. With parallel: 100 − 20 − 20 = 60, net 40% off. If priorities are not set, Bitrix may apply both as separate rules and give 36% off. Or the opposite.
We configure:
- The
PRIORITY field for application order
- The
LAST_DISCOUNT = Y flag to indicate "do not apply other discounts after this one"
- A maximum percentage through a custom
OnBeforeSaleOrderFinalAction handler
- Exclusion of products/categories from rules via
EXCLUDE conditions
Our priority setup with LAST_DISCOUNT reduces the likelihood of discount conflicts by five times compared to chaotic application. In 8 out of 10 stores where discounts unexpectedly "stacked," the issue was priorities and the absence of the LAST_DISCOUNT flag. We fix this during the audit phase.
How to Avoid Conflicts in Cart Rules?
Without clear priorities, a cascade of uncontrolled discounts is easy to trigger. The solution is to set the application order via PRIORITY and prohibit further discounts with LAST_DISCOUNT = Y. For complex promotions (e.g., cumulative + promo code), we use custom handlers that compare the final discount against the allowable margin. This ensures the customer never leaves with a loss-making checkout.
Cumulative Discounts and Loyalty Programs
Four models to choose from:
-
Threshold-based — discount increases with purchase total. Simpler for customers and support.
- Points-based — points earned from purchases, redeemed for rewards. More flexible but harder to understand.
- Tiered — Silver/Gold/Platinum. Gamification retains customers.
- Cashback — returned to internal account (
b_sale_user_account).
Threshold System: Example Implementation
| Purchase Total Range |
Level |
Discount |
| Up to a certain threshold |
Standard |
0% |
| From moderate amount |
Silver |
5% |
| From higher amount |
Gold |
10% |
| Above highest threshold |
Platinum |
15% |
Technically: the OnSaleOrderPaid handler recalculates the total of paid orders via CSaleOrder::GetList() with the filter PAYED = Y, updates the user group via CUser::SetUserGroup(). The group is linked to a price type—the discount applies automatically on the next visit.
Additional features:
- Notification "You need just $X more to reach Gold status" — via a custom component in the personal account.
- Level validity period — annual (recalculated by
CAgent) or permanent.
- Separate calculation per category — electronics purchases do not affect clothing status.
Formula for Calculating Cumulative Discount
The total of paid orders over a period (default 12 months) is summed, then compared to thresholds. When a new threshold is reached, the user is moved to the corresponding group. Example: a customer has made purchases totaling $X — they are in "Silver" (5%). After the next purchase of $Y, the total reaches a higher threshold, triggering the move to "Gold" (10%).
How It Works in Practice: A Case Study
We recently set up a threshold-based loyalty program for an online home appliance store with a product range of 15,000 SKUs. Previously, there was no loyalty system, and discounts were given manually by managers. We implemented a four-level threshold system. Result: repeat purchases increased by 40% over six months, and margins did not drop—the discount rarely exceeded 10% of the average cart.
Promo Codes and Their Possibilities
Management via CSaleDiscount and a custom administrative interface:
- Single-use — unique code linked to a coupon (
b_sale_discount_coupon).
- Multi-use — shared code with a usage limit via
MAX_USE.
- Personal — linked to
USER_ID.
- Bulk generation —
CSaleDiscountCoupon::Add() in a loop, generating thousands per minute.
Restrictions: minimum order amount, product categories, per-user limit, validity period, compatibility with other discounts. Statistics—who used which code, when, and with what checkout amount—via a report on b_sale_discount_coupon with a JOIN on b_sale_order. Linking to UTM tags shows which channel actually drives conversions.
Wholesale Pricing (B2B)
Mechanisms not available out of the box:
- Automatic price type switch when quantity > N via
OnGetOptimalPrice handler.
- Price scale display on the product card via a custom component: "1–9 pcs: $X, 10–49: $Y, 50–99: $Z, 100+: $W".
- Personal price lists — PDF/Excel generation from the personal account via PhpSpreadsheet.
- Special price request form → lead in CRM.
- Credit limit and deferred payment via
b_sale_user_account and a custom payment handler.
Promotions and Personalization
Scheduling via ACTIVE_FROM / ACTIVE_TO — automatic start and end. Countdown timer — JS component linked to the item's ACTIVE_TO. Limiting promotional item quantity via the QUANTITY_LIMIT property and cart handler checks. A "Promotions" section — via smart filter on the IS_SALE = Y property.
Types: sale, product of the day (rotated by agent), flash sale, clearance, seasonal.
Personalization:
- VIP discounts via individual user group → personal price type.
- Corporate terms: deferred payment, custom delivery.
- Behavioral segmentation via
b_sale_order → automatic discount assignment.
- Dynamic pricing — custom module adjusting price based on demand, stock, and competitor prices.
Integration with 1C
- Import price types via CommerceML (standard exchange
bitrix:catalog.import.1c).
- Sync discount cards: card number → user group → price type.
- Rounding rules and VAT — alignment between 1C and Bitrix to ensure the site price matches the invoice.
- Scheduled updates (cron + agent) or real-time via REST API.
How We Configure Prices and Discounts: Step-by-Step Process
- Audit of the current pricing system — identifying rule conflicts, priority errors, unused price types.
- Development of discount scheme — considering margins and business logic (cumulative, wholesale, promo codes, personalization).
- Cart rule configuration — priorities, flags, exceptions.
- 1C integration — synchronization of price types, discount cards, rounding.
- Testing — load testing with 100+ active rules, conflict checks.
- Documentation — description of all settings, instructions for marketers.
- Manager training — how to create and disable promotions without risk.
- 30-day support — fix any anomalies after launch.
Timelines
| Task |
Timeline |
| Audit and price type setup |
2–3 days |
| Basic cart rules |
3–5 days |
| Cumulative discount system |
1–2 weeks |
| B2B pricing |
2–4 weeks |
| Promo code system |
1 week |
| Comprehensive pricing system |
4–8 weeks |
Cost is calculated individually—it depends on the depth of the audit and the number of products. Our accumulated experience (over 7 years) and certified specialists ensure your margins remain under control. Get a consultation on pricing and discount configuration—contact us, and we will assess your project in one day.