Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Language specific forums Russian (Русский) Веб сервер
  • Search

Конфиг nginx для bitrix композит

Вопросы по работе Веб сервера
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
9 posts • Page 1 of 1
radist
Posts: 23
Joined: Sat Sep 07, 2013 7:26 am

Конфиг nginx для bitrix композит
  • Quote

Post by radist » Thu Jun 30, 2016 8:08 am

Добрый день. Помогите переделать конфиг nginx для работы композита bitrix. Переписать в темплейт сам смоугу.

Вот пример конфига из документации 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;
}
Конфиг vestacp

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*;
}
Top

RG22EM
Posts: 92
Joined: Mon Feb 02, 2015 8:40 am

Re: Конфиг nginx для bitrix композит
  • Quote

Post by RG22EM » Thu Jul 14, 2016 12:08 pm

Неужели никто так и не одолел???
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Конфиг nginx для bitrix композит
  • Quote

Post by skurudo » Mon Jul 25, 2016 7:00 am

RG22EM wrote:Неужели никто так и не одолел???
Это не на чем потом тестировать, потому особо так и не смотрели :(
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Конфиг nginx для bitrix композит
  • Quote

Post by skurudo » Mon Jul 25, 2016 7:08 am

radist wrote:Добрый день. Помогите переделать конфиг nginx для работы композита bitrix. Переписать в темплейт сам смоугу.
Вот пример конфига из документации bitrix
Указанный темплейт имхо больше для php-fpm, нежели для апаче.
В каком месте тормозит? Внутренние тесты рассказывают что-нибудь интересное?
Top

radist
Posts: 23
Joined: Sat Sep 07, 2013 7:26 am

Re: Конфиг nginx для bitrix композит
  • Quote

Post by radist » Sun Oct 30, 2016 7:00 pm

Покритикуйте.

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.
Top

radist
Posts: 23
Joined: Sat Sep 07, 2013 7:26 am

Re: Конфиг nginx для bitrix композит
  • Quote

Post by radist » Sun Oct 30, 2016 7:02 pm

skurudo wrote: Указанный темплейт имхо больше для php-fpm, нежели для апаче.
В каком месте тормозит? Внутренние тесты рассказывают что-нибудь интересное?
Указанный пример от сюда
https://dev.1c-bitrix.ru/learning/cours ... ON_ID=2419

На счет тормозов, внутренние тесты попугаев мало дают. bitrix сам умеет отдавать из кеша, но отдача через nginx html файлов всяко шустрее.

PS: если кто использует ruweb vds у них есть темплейт vestacp для битрикса. Поделитесь с общественностью, что там настроено.
Top

skurudo
VestaCP Team
Posts: 8099
Joined: Fri Dec 26, 2014 2:23 pm
Contact:
Contact skurudo
Website Facebook Google+ Skype
Twitter

Re: Конфиг nginx для bitrix композит
  • Quote

Post by skurudo » Tue Nov 01, 2016 2:11 pm

radist wrote:PS: если кто использует ruweb vds у них есть темплейт vestacp для битрикса. Поделитесь с общественностью, что там настроено.
Не знаю даже, что там за темплейт. :(
Top

MrConstantine
Posts: 74
Joined: Wed Nov 18, 2015 12:16 am

Re: Конфиг nginx для bitrix композит
  • Quote

Post by MrConstantine » Wed Nov 02, 2016 6:48 am

radist, вам конфиг nginx + apache или nginx + php-fpm нужен?
Top

radist
Posts: 23
Joined: Sat Sep 07, 2013 7:26 am

Re: Конфиг nginx для bitrix композит
  • Quote

Post by radist » Mon Nov 14, 2016 5:49 pm

MrConstantine wrote:radist, вам конфиг nginx + apache или nginx + php-fpm нужен?
nginx. бекенд не важен.
Top


Post Reply
  • Print view

9 posts • Page 1 of 1

Return to “Веб сервер”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password