Конфиг nginx для bitrix композит
Конфиг nginx для bitrix композит
Добрый день. Помогите переделать конфиг nginx для работы композита bitrix. Переписать в темплейт сам смоугу.
Вот пример конфига из документации bitrix
Конфиг vestacp
Вот пример конфига из документации bitrix
Code: Select all
#### user defined variables
# document root
root /home/bitrix/www;
# apache|php-fpm upstream
set $backend "127.0.0.1:8080";
#### /user defined variables
# default path to cache file
set $test_file "/bitrix/html_pages/$host$uri/index@$args.html";
set $storedAuth "";
set $usecache "";
# check all conditions for enable composite
if ( $http_bx_action_type = "" ) { set $usecache "A"; }
if ( $request_method = "GET" ) { set $usecache "${usecache}B"; }
if ( $cookie_BITRIX_SM_NCC = "" ) { set $usecache "${usecache}C"; }
if ( $http_x_forwarded_scheme !~ "https" ){ set $usecache "${usecache}D"; }
# IE9 and above exclude
modern_browser_value "modern";
modern_browser msie 10.0;
modern_browser unlisted;
if ($modern_browser) {
set $usecache "${usecache}E";
}
# check user auth
if ( $cookie_BITRIX_SM_LOGIN != "" ) { set $storedAuth "A"; }
if ( $cookie_BITRIX_SM_UIDH != "" ) { set $storedAuth "${storedAuth}B"; }
if ( $cookie_BITRIX_SM_CC != "Y" ) { set $storedAuth "${storedAuth}C"; }
if ( $storedAuth !~ "ABC" ) { set $usecache "${usecache}F"; }
## cache location
location ~* @.*\.html$ {
internal;
}
# use default cache file
location / {
if ($usecache != "ABCDEF" ) { proxy_pass http://$backend; }
try_files $test_file @apache;
}
# use own path to cache file: test_file
location ~* ^(.*)\.php$ {
set $test_file "/bitrix/html_pages/$host$1@$args.html";
if ($usecache != "ABCDEF" ) { proxy_pass http://$backend; }
try_files $test_file @apache;
}
# apache location
location @apache {
proxy_pass http://$backend;
}
Code: Select all
server {
listen 146.***.***.***:80;
server_name ***********.ru;
error_log /var/log/apache2/domains/**********.ru.error.log error;
location / {
proxy_pass http://146.***.***.***:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
root /home/pp/web/*******.ru/public_html;
access_log /var/log/apache2/domains/*********.ru.log combined;
access_log /var/log/apache2/domains/*************.ru.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias /home/pp/web/************.ru/document_errors/;
}
location @fallback {
proxy_pass http://146.***.***.***:8080;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/pp/conf/web/nginx.************.ru.conf*;
}
Re: Конфиг nginx для bitrix композит
Неужели никто так и не одолел???
Re: Конфиг nginx для bitrix композит
Это не на чем потом тестировать, потому особо так и не смотрели :(RG22EM wrote:Неужели никто так и не одолел???
Re: Конфиг nginx для bitrix композит
Указанный темплейт имхо больше для php-fpm, нежели для апаче.radist wrote:Добрый день. Помогите переделать конфиг nginx для работы композита bitrix. Переписать в темплейт сам смоугу.
Вот пример конфига из документации bitrix
В каком месте тормозит? Внутренние тесты рассказывают что-нибудь интересное?
Re: Конфиг nginx для bitrix композит
Покритикуйте.
Code: Select all
cat btxcomposite.tpl
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
# default path to cache file
set $test_file "/bitrix/html_pages/$host$uri/index@$args.html";
set $storedAuth "";
set $usecache "";
# check all conditions for enable composite
if ( $http_bx_action_type = "" ) { set $usecache "A"; }
if ( $request_method = "GET" ) { set $usecache "${usecache}B"; }
if ( $cookie_BITRIX_SM_NCC = "" ) { set $usecache "${usecache}C"; }
if ( $http_x_forwarded_scheme !~ "https" ){ set $usecache "${usecache}D"; }
# IE9 and above exclude
modern_browser_value "modern";
modern_browser msie 10.0;
modern_browser unlisted;
if ($modern_browser) {
set $usecache "${usecache}E";
}
# check user auth
if ( $cookie_BITRIX_SM_LOGIN != "" ) { set $storedAuth "A"; }
if ( $cookie_BITRIX_SM_UIDH != "" ) { set $storedAuth "${storedAuth}B"; }
if ( $cookie_BITRIX_SM_CC != "Y" ) { set $storedAuth "${storedAuth}C"; }
if ( $storedAuth !~ "ABC" ) { set $usecache "${usecache}F"; }
## cache location
location ~* @.*\.html$ {
internal;
}
location / {
root %docroot%;
if ($usecache != "ABCDEF" ) { proxy_pass http://%ip%:%web_ssl_port%; }
location ~* ^.+\.(%proxy_extentions%)$ {
root %docroot%;
access_log /var/log/%web_system%/domains/%domain%.log combined;
access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
expires max;
try_files $uri @fallback;
}
try_files $test_file @fallback;
add_header X-Bitrix-Composite "Nginx (file)";
}
location ~* ^(.*)\.php$ {
set $test_file "/bitrix/html_pages/$host$1@$args.html";
if ($usecache != "ABCDEF" ) { proxy_pass http://%ip%:%web_port%; }
try_files $test_file @fallback;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location @fallback {
proxy_pass http://%ip%:%web_port%;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include %home%/%user%/conf/web/nginx.%domain%.conf*;
}
# cat btxcomposite.stpl
server {
listen %ip%:%proxy_ssl_port%;
server_name %domain_idn% %alias_idn%;
ssl on;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
error_log /var/log/%web_system%/domains/%domain%.error.log error;
# default path to cache file
set $test_file "/bitrix/html_pages/$host$uri/index@$args.html";
set $storedAuth "";
set $usecache "";
# check all conditions for enable composite
if ( $http_bx_action_type = "" ) { set $usecache "A"; }
if ( $request_method = "GET" ) { set $usecache "${usecache}B"; }
if ( $cookie_BITRIX_SM_NCC = "" ) { set $usecache "${usecache}C"; }
if ( $http_x_forwarded_scheme !~ "https" ){ set $usecache "${usecache}D"; }
# IE9 and above exclude
modern_browser_value "modern";
modern_browser msie 10.0;
modern_browser unlisted;
if ($modern_browser) {
set $usecache "${usecache}E";
}
# check user auth
if ( $cookie_BITRIX_SM_LOGIN != "" ) { set $storedAuth "A"; }
if ( $cookie_BITRIX_SM_UIDH != "" ) { set $storedAuth "${storedAuth}B"; }
if ( $cookie_BITRIX_SM_CC != "Y" ) { set $storedAuth "${storedAuth}C"; }
if ( $storedAuth !~ "ABC" ) { set $usecache "${usecache}F"; }
## cache location
location ~* @.*\.html$ {
internal;
}
location / {
root %sdocroot%;
if ($usecache != "ABCDEF" ) { proxy_pass https://%ip%:%web_ssl_port%; }
location ~* ^.+\.(%proxy_extentions%)$ {
root %sdocroot%;
access_log /var/log/%web_system%/domains/%domain%.log combined;
access_log /var/log/%web_system%/domains/%domain%.bytes bytes;
expires max;
try_files $uri @fallback;
}
try_files $test_file @fallback;
add_header X-Bitrix-Composite "Nginx (file)";
}
location ~* ^(.*)\.php$ {
set $test_file "/bitrix/html_pages/$host$1@$args.html";
if ($usecache != "ABCDEF" ) { proxy_pass https://%ip%:%web_port%; }
try_files $test_file @fallback;
}
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location @fallback {
proxy_pass https://%ip%:%web_ssl_port%;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include %home%/%user%/conf/web/snginx.%domain%.conf*;
}
Last edited by radist on Mon Oct 31, 2016 7:43 am, edited 3 times in total.
Re: Конфиг nginx для bitrix композит
Указанный пример от сюдаskurudo wrote: Указанный темплейт имхо больше для php-fpm, нежели для апаче.
В каком месте тормозит? Внутренние тесты рассказывают что-нибудь интересное?
https://dev.1c-bitrix.ru/learning/cours ... ON_ID=2419
На счет тормозов, внутренние тесты попугаев мало дают. bitrix сам умеет отдавать из кеша, но отдача через nginx html файлов всяко шустрее.
PS: если кто использует ruweb vds у них есть темплейт vestacp для битрикса. Поделитесь с общественностью, что там настроено.
Re: Конфиг nginx для bitrix композит
Не знаю даже, что там за темплейт. :(radist wrote:PS: если кто использует ruweb vds у них есть темплейт vestacp для битрикса. Поделитесь с общественностью, что там настроено.
-
- Posts: 74
- Joined: Wed Nov 18, 2015 12:16 am
Re: Конфиг nginx для bitrix композит
radist, вам конфиг nginx + apache или nginx + php-fpm нужен?
Re: Конфиг nginx для bitrix композит
nginx. бекенд не важен.MrConstantine wrote:radist, вам конфиг nginx + apache или nginx + php-fpm нужен?