Bitrix Nginx Routing
Bitrix uses its own URL rewriting layer. nginx must pass Bitrix-friendly requests and variables to PHP-FPM, otherwise human-readable URLs, subdomains, or legacy URL-building code can behave differently from Apache-based hosting.
What Must Be True
For the Bitrix profile, nginx config should include:
- fallback to
/bitrix/urlrewrite.phpfor Bitrix SEF/CHPU URLs client_max_body_size 64mfor common Bitrix uploadsSERVER_NAMEandHTTP_HOSTforwarded to PHP-FPM- root domain and wildcard hostnames when wildcard host mode is enabled
bitrix status and site doctor check the most important nginx contract pieces.
SEF/CHPU Fallback
For normal human-readable URLs, nginx must fall back to:
/bitrix/urlrewrite.php?$args
not directly to:
/index.php
This matters for pages such as:
/news/10487/
/doc/personal-data/
/sveden-camp/about-camp/document-camp/
If these URLs are routed directly to /index.php, Bitrix can open the wrong content, skip route rules, or behave differently from the same project on Apache.
SERVER_NAME And HTTP_HOST
The Bitrix profile forwards Apache-like request variables to PHP-FPM, including:
SERVER_NAME
HTTP_HOST
REQUEST_SCHEME
SERVER_PORT
HTTPS
Use HTTP_HOST when application logic must know the exact incoming host, especially on wildcard/subdomain sites:
camp.example.ru
test.example.ru
b24.example.ru
SERVER_NAME can be normalized by nginx/server config. Legacy Bitrix code may still read it, so the profile forwards it, but host-sensitive project logic should prefer HTTP_HOST where possible.
Wildcard Host Mode
When a site is created with:
Serve all first-level subdomains too? -> yes
nginx should serve both:
example.ru
*.example.ru
This only routes requests to the same Bitrix project. It does not automatically make Bitrix multi-tenant. The application must still decide what to do for each host.
Wildcard host mode covers first-level subdomains only:
camp.example.ru
It does not cover multi-level subdomains:
a.b.example.ru
How To Check
Menu:
Sites -> Site info
Applications -> Bitrix -> Bitrix status
Diagnostics -> Site health check
CLI:
sudo /root/simai-env/simai-admin.sh site info --domain <domain>
sudo /root/simai-env/simai-admin.sh bitrix status --domain <domain>
sudo /root/simai-env/simai-admin.sh site doctor --domain <domain>
Expected Bitrix nginx checks:
Bitrix SEF fallback: /bitrix/urlrewrite.php
Bitrix upload body limit: client_max_body_size 64m
For wildcard sites, site info should show host mode and hostnames:
Host mode: wildcard
Hostnames: example.ru, *.example.ru
How To Reproduce Host-Specific Issues
From the server, test the same local nginx site with different hosts:
curl -I -H "Host: <domain>" http://127.0.0.1/
curl -I -H "Host: test.<domain>" http://127.0.0.1/
For a Bitrix route:
curl -I -H "Host: <domain>" http://127.0.0.1/news/10487/
curl -I -H "Host: test.<domain>" http://127.0.0.1/news/10487/
This checks nginx routing without waiting for external DNS.
Common Symptoms
CHPU page opens wrong content:
- check
Bitrix SEF fallback - expected fallback is
/bitrix/urlrewrite.php
Subdomain opens root-domain behavior:
- check wildcard host mode in
site info - check DNS wildcard
Arecord - check application logic that reads
HTTP_HOST
$_SERVER["SERVER_NAME"] or $_SERVER["HTTP_HOST"] differs from Apache:
- check
bitrix status - inspect nginx config if the site was migrated before the current Bitrix template
- prefer
HTTP_HOSTfor exact incoming host in application logic
Manual nginx edits disappeared after SSL change:
- regenerate or patch through simai-env where possible
- SSL commands should preserve Bitrix template metadata
- run
site doctorafter SSL operations
Repair Direction
If site doctor reports missing Bitrix nginx checks, the safe direction is to restore the Bitrix nginx template contract rather than hand-editing unrelated blocks.
Important checks:
client_max_body_size 64m
try_files $uri $uri/ /bitrix/urlrewrite.php?$args
fastcgi_param SERVER_NAME $host
fastcgi_param HTTP_HOST $host
After any nginx change:
sudo nginx -t
sudo systemctl reload nginx
sudo /root/simai-env/simai-admin.sh site doctor --domain <domain>
Handoff Checklist
Before saying Bitrix nginx routing is ready:
site infoshowsProfile: bitrixbitrix statusreports Bitrix SEF fallback readysite doctorreports Bitrix nginx checks as pass- wildcard host mode is enabled when subdomains are required
- root and subdomain hosts open the expected Bitrix application
- large uploads are covered by Uploads