Nginx Configuration for 1C-Bitrix: Security, Caching, Composite
Imagine: you've just moved an e-commerce store to a new server, and customers see 404 on catalog pages. Diagnostics show PHP is working, but SEF URLs are not processed. The cause is missing correct try_files in the Nginx configuration. From our experience, 80% of site display problems on Bitrix after changing hosting are due to this. We solve such issues in 1–2 days by providing a ready-made configuration optimized for high loads. Our experience in Bitrix server setup is over 10 years, with more than 300 projects completed. Contact us for a server audit.
Nginx Configuration for Bitrix: try_files Setup
Without a correct try_files, any URL that does not correspond to a physical file returns 404. Bitrix uses a single entry point /bitrix/urlrewrite.php, so all requests must be directed to it. A mistake in passing $is_args$args leads to loss of GET parameters — a typical problem we see in every second project after migration. The correct Nginx configuration for Bitrix includes exactly this approach.
location / { try_files $uri $uri/ /bitrix/urlrewrite.php$is_args$args; } Official 1C-Bitrix documentation recommends this exact approach.
What Does Nginx Configuration Bring for Security?
Closing service directories is a basic but mandatory measure. Open access to /bitrix/backup/ can lead to leakage of backups with the database, which is critical for compliance with Federal Law 152. We always block these directories.
location ~* ^/bitrix/(backup|modules|php_interface|tools)/ { deny all; return 403; } location ~ /\. { deny all; return 404; } location ~* ^/upload/.*\.php$ { deny all; return 403; } The /upload directory should serve files but not execute PHP — this is a vector for uploading web shells. We additionally enable open_basedir in PHP-FPM for isolation.
Why Static Caching and gzip Are Crucial
Setting expires 30d and immutable allows the browser not to request static files again, reducing server load by up to 70% for repeat visits. This minimizes latency and bandwidth consumption.
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf)$ { expires 30d; add_header Cache-Control "public, immutable"; access_log off; } immutable tells the browser: the file will not change until expires expires. Works for versioned Bitrix files (/bitrix/cache/css/[hash].css).
| File Type | Directory | Cache Time | Cache-Control |
|---|---|---|---|
| JS, CSS | /bitrix/cache/ | 30 days | public, immutable |
| PNG, JPG | /upload/ | 7 days | public, immutable |
| SVG, WOFF | /bitrix/ | 30 days | public, immutable |
gzip Compression
gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_comp_level 5; gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml; Level 5 is a balance between CPU and compression. Levels 7–9 give minimal gain with noticeable CPU load increase. Enabling gzip_vary is mandatory for correct operation with proxy servers.
How to Speed Up Bitrix Using Composite and Nginx
Bitrix Composites store HTML in /bitrix/html_pages/. Nginx can serve these files without PHP, providing a 10–50 times speed boost for unauthenticated visitors. Configured Nginx with Composite delivers pages 10–50 times faster than standard PHP-FPM stack without caching.
location / { set $cache_path "/bitrix/html_pages${uri}"; if (-f "${document_root}${cache_path}.html") { rewrite ^ ${cache_path}.html last; } try_files $uri $uri/ /bitrix/urlrewrite.php$is_args$args; } location ~* /bitrix/html_pages/ { internal; add_header X-Bitrix-Composite "HIT"; } Combining HTML cache with Nginx achieves performance of up to 10,000 requests per second on a single server. Savings on server loads can be substantial for a high-traffic store — in one project, we reduced infrastructure costs by 30%, translating to approximately $500/month savings.
Example of a full Nginx configuration for Bitrix
The full configuration includes all the blocks described above, plus PHP-FPM settings and limits. We deliver it in a deploy-ready format.
Case Study: Incorrect try_files (From Our Practice)
A client — an e-commerce store after server migration. All catalog pages returned 404, but the homepage worked. The cause: the config had try_files $uri $uri/ @bitrix; with a named location @bitrix that did not pass $args. Result: the URL /catalog/electronics/?SECTION_ID=5 lost parameters. After fixing to the standard try_files $uri $uri/ /bitrix/urlrewrite.php$is_args$args, everything worked. This error occurs in 30% of projects when migrating from Apache to Nginx.
What's Included in the Nginx Configuration Service
| Component | Duration | Description |
|---|---|---|
| Audit of current configuration | 2–4 hours | Check existing settings, identify vulnerabilities and bottlenecks |
| Try_files and security setup | 2–4 hours | Correct redirects, close service directories, configure open_basedir |
| Static caching and gzip | 1–2 hours | Set caching headers, configure gzip for traffic savings |
| Composite optimization | 1–2 hours | Enable Nginx internal cache for HTML pages |
| Load testing | 2–4 hours | Test under load, measure performance (req/s) |
| Documentation and support | 1 hour | Provide detailed configuration documentation, 24-hour post-deployment monitoring, and email support |
Process of Work
- Analysis — study current configuration, server architecture.
- Design — prepare configuration considering information blocks, load, and security requirements.
- Implementation — apply changes to Nginx, configure PHP-FPM, test on staging.
- Testing — check all site sections, including SEF URLs, cart, personal account.
- Deployment — move to production, monitor for 24 hours, then hand over documentation.
Timelines and Cost
Nginx configuration for Bitrix from scratch takes from 1 to 3 days. The typical cost ranges from $800 to $1,500 depending on infrastructure complexity. Includes audit, implementation, testing, and documentation handover. We also offer ongoing support retainers starting at $200/month.
Ready to optimize your Bitrix? Order a turnkey configuration — get a ready-to-deploy config with documentation. We guarantee compatibility with official updates and security. Contact us for an audit.

