V
V
VA2016-05-17 18:07:03
MySQL
VA, 2016-05-17 18:07:03

Optimal setup of 2 sites (back-apache, front-nginx)?

Hi all!
My question will seem very common to most people.
In general, there is a dedicated server, with one IP, on CentOS, Apache web, Nginx, + Bitrix CMS.
While setting it up for moving. Faced with a trivial question at first glance.
There will be two sites (with different domain names, for example:
the first one = prodazha.ru;
the second one = pokupka.ru;
the first site is prodazha.ru, its frontend is NGINX:

spoiler
# first website
  server {

    listen 80 prodazha.ru;  #если их резолвить, то каким способом избежать ошибок? 
    server_name _;
    server_name_in_redirect off;

    proxy_set_header	X-Real-IP        $remote_addr;
    proxy_set_header	X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header	Host $host:80;

    set $proxyserver	"http://127.0.0.1:8888";
    set $docroot		"/home/bitrix/www";

    index index.php;
    root /home/bitrix/www;

    # Redirect to ssl if need
    if (-f /home/bitrix/www/.htsecure) { rewrite ^(.*)$ https://$host$1 permanent; }

    # Include parameters common to all websites
    include bx/conf/bitrix.conf;

    # Include server monitoring locations
    include bx/server_monitor.conf;

location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $request_filename;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }
    
  }


and its Apache backend:
spoiler
Listen 127.0.0.1:8888
<VirtualHost 127.0.0.1:8888>
  ServerAdmin [email protected]
  DocumentRoot /home/bitrix/www

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>

  <DirectoryMatch .*\.svn/.*>
     Deny From All
  </DirectoryMatch>

  <DirectoryMatch .*\.git/.*>
     Deny From All
  </DirectoryMatch>

  <DirectoryMatch .*\.hg/.*>
     Deny From All
  </DirectoryMatch>

  <Directory /home/bitrix/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    DirectoryIndex index.php index.html index.htm
    Order allow,deny
    allow from all
    php_admin_value session.save_path /tmp/php_sessions/www
    php_admin_value upload_tmp_dir /tmp/php_upload/www
  </Directory>

  <Directory /home/bitrix/www/bitrix/cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /home/bitrix/www/bitrix/managed_cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /home/bitrix/www/bitrix/local_cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /home/bitrix/www/bitrix/stack_cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /home/bitrix/www/upload>
    AllowOverride none
    AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
    php_value engine off
  </Directory>

  <Directory /home/bitrix/www/upload/support/not_image>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /home/bitrix/www/bitrix/images>
    AllowOverride none
    AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
    php_value engine off
  </Directory>

  <Directory /home/bitrix/www/bitrix/tmp>
    AllowOverride none
    AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
    php_value engine off
  </Directory>

  ErrorLog logs/error_log
  # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
  LogLevel warn

  CustomLog logs/access_log combined

  <IfModule mod_rewrite.c>
    #Nginx should have "proxy_set_header HTTPS YES;" in location
    RewriteEngine On
    RewriteCond %{HTTP:HTTPS} =YES
    RewriteRule .* - [E=HTTPS:on,L]
  </IfModule>
</VirtualHost>


The second site pokupka.ru, its frontend NGINX:
spoiler
# Second website
  server {

    listen 80 pokupka.ru;
    server_name _;
    server_name_in_redirect off;

    proxy_set_header	X-Real-IP        $remote_addr;
    proxy_set_header	X-Forwarded-For  $proxy_add_x_forwarded_for;
    proxy_set_header	Host $host:80;

    set $proxyserver	"http://127.0.0.1:8889";
    set $docroot		"/var/www/pokupka";

    index index.php;
    root /var/www/pokupka;

    # Redirect to ssl if need
    if (-f /home/bitrix/www/.htsecure) { rewrite ^(.*)$ https://$host$1 permanent; }

    # Include parameters common to all websites
    include bx/conf/bitrix.conf;

    # Include server monitoring locations
    include bx/server_monitor.conf;

location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $request_filename;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }
    
  }


and its backend apache
spoiler
Listen 127.0.0.1:8889
<VirtualHost 127.0.0.1:8889>
  ServerAdmin [email protected]
  DocumentRoot /var/www/pokupka

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>

  <DirectoryMatch .*\.svn/.*>
     Deny From All
  </DirectoryMatch>

  <DirectoryMatch .*\.git/.*>
     Deny From All
  </DirectoryMatch>

  <DirectoryMatch .*\.hg/.*>
     Deny From All
  </DirectoryMatch>

  <Directory /var/www/pokupka/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    DirectoryIndex index.php index.html index.htm
    Order allow,deny
    allow from all
    php_admin_value session.save_path /tmp/php_sessions/www
    php_admin_value upload_tmp_dir /tmp/php_upload/www
  </Directory>

  <Directory /var/www/pokupka/bitrix/cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /var/www/pokupka/bitrix/managed_cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /var/www/pokupka/bitrix/local_cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /var/www/pokupka/bitrix/stack_cache>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /var/www/pokupka/upload>
    AllowOverride none
    AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
    php_value engine off
  </Directory>

  <Directory /var/www/pokupka/upload/support/not_image>
    AllowOverride none
    Order allow,deny
    Deny from all
  </Directory>

  <Directory /var/www/pokupka//bitrix/images>
    AllowOverride none
    AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
    php_value engine off
  </Directory>

  <Directory /var/www/pokupka/bitrix/tmp>
    AllowOverride none
    AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
    php_value engine off
  </Directory>

  ErrorLog logs/error_log
  # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
  LogLevel warn

  CustomLog logs/access_log combined

  <IfModule mod_rewrite.c>
    #Nginx should have "proxy_set_header HTTPS YES;" in location
    RewriteEngine On
    RewriteCond %{HTTP:HTTPS} =YES
    RewriteRule .* - [E=HTTPS:on,L]
  </IfModule>
</VirtualHost>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-05-18
@shambler81

if it's centos and bitrix sites, then a reasonable question arises
: why not "bitrix web environment" ??

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question