Редактируем
/etc/nginx/nginx.conf
Код |
---|
user bitrix;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_rlimit_nofile 10240;
events {
use epoll;
worker_connections 10240;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format common '$remote_addr - - [$time_local] "$request" $status $bytes_sent "$http_referer" "$http_user_agent" $msec';
access_log /var/log/nginx/access.log common;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 8 64k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 10m;
gzip on;
gzip_proxied any;
gzip_types application/x-javascript text/css;
server {
listen 80;
server_name bitrix;
server_name_in_redirect off;
access_log /var/log/nginx/access.log common;
index index.php;
error_page 500 502 503 504 /500.html;
error_page 404 = /404.php;
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;
client_max_body_size 1024M;
client_body_buffer_size 4M;
if (!-d /home/$host/www ) {
set $cur_host "default";
}
if (-d /home/$host/www ) {
set $cur_host $host;
}
root /home/$cur_host/www;
if (-f /home/$cur_host/www/.htsecure) {
rewrite ^(.*)$ https://$host$1 permanent;
}
location / { expires 3d;
if ($request_method = OPTIONS ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = PROPFIND ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = PROPPATCH ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = MKCOL ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = COPY ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = MOVE ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = LOCK ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = UNLOCK ) {
proxy_pass http://127.0.0.1:8888;
}
}
location ~ ^(/extranet/docs|/docs|/workgroups|/company/profile|/bitrix/tools|/company/personal/user).*/$ {
proxy_pass http://127.0.0.1:8888;
}
location ~ ^(/extranet/docs|/docs|/workgroups|/company/profile|/bitrix/tools|/company/personal/user) {
if (-d $request_filename) {
rewrite ^(.*)(/*)$ $1/ last;
}
proxy_pass http://127.0.0.1:8888;
}
location ~ ^(/bitrix/html_pages)
{
root /home/$cur_host/www;
index index@.html;
if (!-f $request_filename)
{
rewrite ^/bitrix/html_pages(.*)@(.*)\.html$ $1.php?$2 break;
rewrite ^/bitrix/html_pages(.*)\.html$ $1\.php break;
proxy_pass http://127.0.0.1:8888;
}
}
location ~ \.php$ {
root /home/$cur_host/www;
if ($request_method = POST ) {
break;
proxy_pass http://127.0.0.1:8888;
}
if ($http_cookie !~ "PHPSESSID=" ) {
rewrite ^(.*)\.php$ /bitrix/html_pages$1@$args.html? last;
}
proxy_pass http://127.0.0.1:8888;
}
location ~ /$ {
root /home/$cur_host/www;
if ($request_method = POST ) {
break;
proxy_pass http://127.0.0.1:8888;
}
if ($http_cookie !~ "PHPSESSID=" ) {
rewrite ^(.*)/$ /bitrix/html_pages$1/index@$args.html? last;
}
proxy_pass http://127.0.0.1:8888;
}
location ~ (/|\.php|\.asmx)$ {
proxy_pass http://127.0.0.1:8888;
}
location ~ /\.ht {
deny all;
}
location ~ /favicon.ico {
proxy_pass http://127.0.0.1:8888;
}
location ~ ^(/bitrixsetup\.php)$ {
proxy_pass http://127.0.0.1:8888;
proxy_buffering off;
}
}
server {
listen 443;
keepalive_timeout 70;
#->
keepalive_requests 150;
#<-
server_name bitrix;
ssl on;
# ssl_protocols SSLv3 TLSv1;
# ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
ssl_certificate /etc/nginx/cert.pem;
ssl_certificate_key /etc/nginx/cert.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server_name_in_redirect off;
access_log /var/log/nginx/access.log main;
index index.php;
error_page 500 502 503 504 /500.html;
error_page 404 = /404.php;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:443;
client_max_body_size 1024M;
client_body_buffer_size 4M;
proxy_set_header HTTPS YES;
if (!-d /home/$host/www ) {
set $cur_host "default";
}
if (-d /home/$host/www ) {
set $cur_host $host;
}
root /home/$cur_host/www;
location / { expires 3d;
if ($request_method = OPTIONS ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = PROPFIND ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = PROPPATCH ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = MKCOL ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = COPY ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = MOVE ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = LOCK ) {
proxy_pass http://127.0.0.1:8888;
}
if ($request_method = UNLOCK ) {
proxy_pass http://127.0.0.1:8888;
}
}
location ~ ^(/extranet/docs|/docs|/workgroups|/company/profile|/bitrix/tools|/company/personal/user).*/$ {
proxy_pass http://127.0.0.1:8888;
}
location ~ ^(/extranet/docs|/docs|/workgroups|/company/profile|/bitrix/tools|/company/personal/user) {
if (-d $request_filename) {
rewrite ^(.*)(/*)$ $1/ last;
}
proxy_pass http://127.0.0.1:8888;
}
location ~ ^(/bitrix/html_pages)
{
root /home/$cur_host/www;
index index@.html;
if (!-f $request_filename)
{
rewrite ^/bitrix/html_pages(.*)@(.*)\.html$ $1.php?$2 break;
rewrite ^/bitrix/html_pages(.*)\.html$ $1\.php break;
proxy_pass http://127.0.0.1:8888;
}
}
location ~ \.php$ {
root /home/$cur_host/www;
if ($request_method = POST ) {
break;
proxy_pass http://127.0.0.1:8888;
}
if ($http_cookie !~ "PHPSESSID=" ) {
rewrite ^(.*)\.php$ /bitrix/html_pages$1@$args.html? last;
}
proxy_pass http://127.0.0.1:8888;
}
location ~ /$ {
root /home/$cur_host/www;
if ($request_method = POST ) {
break;
proxy_pass http://127.0.0.1:8888;
}
if ($http_cookie !~ "PHPSESSID=" ) {
rewrite ^(.*)/$ /bitrix/html_pages$1/index@$args.html? last;
}
proxy_pass http://127.0.0.1:8888;
}
location ~ (/|\.php|\.asmx)$ {
proxy_pass http://127.0.0.1:8888;
}
location ~ /\.ht {
deny all;
}
location ~ /favicon.ico {
proxy_pass http://127.0.0.1:8888;
}
location ~ ^(/bitrixsetup\.php)$ {
proxy_pass http://127.0.0.1:8888;
proxy_buffering off;
}
}
}
|
теперь каждый сайт должен лежать в папке /home/site_1.lan/www/ /home/site_2.lan/www/ и т.д.
в /etc/apache2/sites-enabled создаем конфиги сайтов, для удобства 1 файл 1 сайт
к примеру файл test
Код |
---|
<VirtualHost *:8888>
ServerAdmin webmaster@localhost
ServerName test.local
ServerAlias www.test.local
DocumentRoot /home/test.local/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/test.local/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php index.html index.htm
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/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>
|
ну и само собой необходимо настроить DNS для локальных адресов, данный вариант не идеален, так что любые поправки будут очень полезны