@Ozymandis
зелень

Оптимальная настройка 2ух сайтов (back-apache, front-nginx)?

Всем Привет!
Вопрос мой покажется очень обычным на взгляд большинства.

В общем есть выделеный сервер, с одним IP, на CentOS, веб- Apache, Nginx, + CMS Битрикс.
Пока настраиваю его для переезда. Столкнулся с тривиальным на первый взгляд вопросом.

Будут два сайта (с разными доменными именами, например:
первый = prodazha.ru;
второй = pokupka.ru;

первый сайт prodazha.ru, его frontend 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;
        }
		
	}



и его backend Apache:
spoiler
Listen 127.0.0.1:8888
<VirtualHost 127.0.0.1:8888>
	ServerAdmin webmaster@localhost
	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>



Второй сайт pokupka.ru, его 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;
        }
		
	}



и его бэкэнд апач
spoiler
Listen 127.0.0.1:8889
<VirtualHost 127.0.0.1:8889>
	ServerAdmin admin@pokupka.ru
	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>

  • Вопрос задан
  • 833 просмотра
Пригласить эксперта
Ответы на вопрос 1
уж если это центос и битрикс сайты то встает целесообразный вопрос
а почему не "битрикс веб окружение" ??
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
Wanted. Москва
До 200 000 ₽
div. Ставрополь
от 50 000 до 120 000 ₽
Lachestry Таганрог
от 170 000 до 200 000 ₽