Setting up HTTP/2 for 1C-Bitrix
A Bitrix page under HTTP/1.1 opens 6–8 parallel TCP connections to one domain and loads JS and CSS sequentially within each. With 30–40 resources on the page — this creates a wait queue. HTTP/2 multiplexes all requests in one connection: the browser requests 40 files simultaneously, the server responds without connection overhead. In practice — 200–400 ms savings on TTI (Time to Interactive).
HTTP/2 Requirements
HTTP/2 works only over TLS in browsers (technically the protocol allows h2c — without encryption, but no browser supports it). This means a valid SSL certificate is needed.
Nginx supports HTTP/2 starting with version 1.9.5. Check:
nginx -V 2>&1 | grep "http_v2"
# Should be: --with-http_v2_module
OpenSSL must support ALPN:
nginx -V 2>&1 | grep "openssl"
openssl version
# OpenSSL 1.0.2+ supports ALPN
Nginx Configuration for HTTP/2
In the virtual host config:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.ru www.example.ru;
ssl_certificate /etc/ssl/certs/example.ru.crt;
ssl_certificate_key /etc/ssl/private/example.ru.key;
# Modern cipher suites (HTTP/2 forbids outdated ones)
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# HSTS (after testing)
add_header Strict-Transport-Security "max-age=63072000" always;
# TLS optimization
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_session_tickets off;
root /var/www/bitrix/public_html;
index index.php;
}
# HTTP -> HTTPS redirect
server {
listen 80;
server_name example.ru www.example.ru;
return 301 https://$host$request_uri;
}
Server Push for Critical Resources
HTTP/2 Server Push allows the server to send CSS and JS before the browser parses HTML and requests them itself. For Bitrix this makes sense for main CSS and the core JS bundle.
In Nginx config for Bitrix (assuming standard /bitrix/ structure):
location = / {
http2_push /bitrix/templates/.default/styles.css;
http2_push /bitrix/js/main/core/core.js;
http2_push /bitrix/themes/.default/icons/sm/logo.png;
}
Or via Link header from PHP:
// At the beginning of the site template, before HTML output
header('Link: </bitrix/templates/.default/styles.css>; rel=preload; as=style', false);
header('Link: </bitrix/js/main/core/core.js>; rel=preload; as=script', false);
Nginx with http2_push_preload on automatically converts Link: rel=preload headers to Server Push.
Buffer Optimization for HTTP/2
HTTP/2 multiplexes streams in one TCP connection, changing buffer behavior:
http {
# For HTTP/2 you can reduce the number of workers per connection
# HTTP/2 keepalive holds connection longer
keepalive_timeout 65;
# Initial window size for HTTP/2
http2_chunk_size 8k;
# Maximum concurrent streams (requests) in one connection
http2_max_concurrent_streams 128;
# Buffers for headers (HTTP/2 compresses headers via HPACK)
http2_recv_buffer_size 256k;
}
Testing HTTP/2 Functionality
# Via curl
curl -I --http2 https://example.ru/
# Response should contain: HTTP/2 200
# Detailed with negotiation
curl -v --http2 https://example.ru/ 2>&1 | grep -E "HTTP/|ALPN"
# Chrome DevTools → Network → Protocol column: h2
Bitrix and CDN with HTTP/2
If static files are served through CDN (Cloudflare, custom), make sure the CDN supports HTTP/2 between browser and CDN. CDN → origin connection can be HTTP/1.1 — that's fine, the bottleneck is usually browser → CDN.
Common Issue: Mixed Content
After switching to HTTPS + HTTP/2, Bitrix may generate links like http://... for static files. This is blocked by the browser as Mixed Content. Check in dbconn.php:
$_SERVER["HTTPS"] = "on";
define("SITE_SERVER_NAME", "example.ru");
And in Bitrix main module settings — "Use secure connection (https)".







