/etc/hosts
на backend серверах сопоставление доменов с frontend сервером (именно frontend!). Если при этом требуется, чтобы сервер мог обращаться ещё и сам к себе по некоторому доменному имени (это надо например push-server
в Битрикс), то надо прописать любое выдуманное имя хоста в /etc/hostname, и отдельной записью прописать его на локальный IP в /etc/hosts
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-stream_realip_module
user www-data;
worker_processes auto;
worker_rlimit_nofile 10240;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
use epoll;
worker_connections 30720;
multi_accept on;
}
stream {
proxy_protocol on; #обязательно включаем, без него IP адреса из приходящего SSL трафика не передать дальше
map $ssl_preread_server_name $name {
siteone.ru so;
sitetwo.ru st;
sitetree.ru str;
}
#bitrix1
upstream so80 {
server 192.168.0.100:80;
}
upstream so443 {
server 192.168.0.100:443;
}
upstream so8893 {
server 192.168.0.100:8893;
}
upstream so8894 {
server 192.168.0.100:8894;
}
#bitrix2
upstream st80 {
server 192.168.88.114:80;
}
upstream st443 {
server 192.168.88.114:443;
}
upstream st8893 {
server 192.168.88.114:8893;
}
upstream st8894 {
server 192.168.88.114:8894;
}
#web site
upstream str80 {
server 192.168.88.102:80;
}
upstream str443 {
server 192.168.88.102:443;
}
#web traffic
server {
listen 80;
proxy_pass ${name}80;
}
server {
listen 443;
proxy_pass ${name}443;
ssl_preread on;
}
#push&pull bitrix
server {
listen 8893;
proxy_pass ${name}8893;
}
server {
listen 8894;
proxy_pass ${name}8894;
ssl_preread on;
}
}
listen
дописываем proxy_protocol
, иначе вообще не заработает.server {
listen 443 default_server ssl proxy_protocol;
...
proxy_set_header X-Real-IP $proxy_protocol_addr;
proxy_set_header X-Forwarded-For $proxy_protocol_addr;
...
}
http
http {
set_real_ip_from #IP вашего frontend#;
real_ip_header proxy_protocol;
}
/etc/hosts
как описано выше. http { ... }
stream {
map $ssl_preread_server_name $name {
site1.ru site1;
site2.ru site2;
}
upstream site1p80 {
server 192.168.88.231:80;
}
upstream site1p443 {
server 192.168.88.231:443;
}
upstream site1p8893 {
server 192.168.88.231:8893;
}
upstream site1p8894 {
server 192.168.88.231:8894;
}
upstream site2p80 {
server 192.168.88.180:80;
}
upstream site2p443 {
server 192.168.88.180:443;
}
upstream site2p8893 {
server 192.168.88.180:8893;
}
upstream site2p8894 {
server 192.168.88.180:8894;
}
server {
listen 443;
proxy_pass ${name}p443;
ssl_preread on;
}
server {
listen 80;
proxy_pass ${name}p80;
}
server {
listen 8893;
proxy_pass ${name}p8893;
}
server {
listen 8894;
proxy_pass ${name}p8894;
}
}
$FieldCode = 'UF_CRM_1728545307';
$UF_instance = \Bitrix\Crm\UserField\UserFieldManager::getUserFieldEntity(CCrmOwnerType::Company); //entityTypeID
$UF_arr = $UF_instance->GetFieldById($FieldCode);
$UF_title = $UF_arr['EDIT_FORM_LABEL'];
use Bitrix\Crm\Service;
$instanceOfCRM = Service\Container::getInstance();
$factoryDeal = $instanceOfCRM->getFactory(2);
$factoryCompany = $instanceOfCRM->getFactory(4);
$Deal = $factoryDeal->getItem($DEAL_ID);
$COMPANY_ID = $Deal->get('COMPANY_ID');
$Company = $factoryCompany->getItem($COMPANY_ID);
$Status = new CCrmStatus('INDUSTRY');
$CompanyINDUSTRY = ($Status->GetStatusByStatusId($Company->get('INDUSTRY')))['NAME'];
$CompanyINDUSTRY = ($CompanyINDUSTRY) ?: 'Сфера деятельности не указана';
Reply that 90:98:77:65:9F:33 is 192.168.37.227 in 133.770ms
90:98:77:65:9F:34
foreach ($parents as $parent) {
$objArr = (array)$parent;
foreach ($objArr as $key => $value) {
$ID[explode("\0",$key)[2]] = $value;
}
file_put_contents($_SERVER['DOCUMENT_ROOT'] . '/cust_app/php_applets_for_bp/logRelRes.txt', print_r($ID, 1));
}
Array
(
[entityTypeId] => 4
[entityId] => 115695
[categoryId] =>
)
Не знаю как красивее сделать, нужна помощь экспертов.
событие на получение почты onMailMessageNew
<?php
use Bitrix\Main\Diag\Debug;
use Bitrix\Mail\Helper\Message;
use \Bitrix\Main\Entity\Event;
CModule::IncludeModule('mail');
$eventManager = \Bitrix\Main\EventManager::getInstance();
$eventManager->addEventHandler('mail', 'onMailMessageNew', 'onMailMessageNew');
function onMailMessageNew($event)
{
$message = $event->getParameter('message');
Debug::dumpToFile( $message);
}
debug_backtrace()
, его вставил с выводом результата в файл в оригинальный файл ./bitrix/components/bitrix/report.view/stexport.ajax.php
и оказалось, что вызывался он из файла другого компонента:Array
(
[0] => Array
(
[file] => /home/bitrix/www/bitrix/components/bitrix/crm.report.view/stexport.ajax.php
[line] => 5
[function] => include_once
)
)
crm.report.view
в папку ./local/components/bitrix/report.view
, сделал подмену ./bitrix/
на ./local/
во всех файлах компонента crm.report.view
(искал grep -rn "/bitrix/com" .
) и вуаля, всё взлетело! CModule::IncludeModule("crm");
$arRQAddr['6'] = [ //1 - Физический адрес, 6 -Юридический адрес
'ADDRESS_1' => 'ул. Семашко, д.1',
'ADDRESS_2' => '',
'POSTAL_CODE' => '355029',
'PROVINCE' => 'Ставропольский край',
'CITY' => 'город Ставрополь',
'COUNTRY' => "Россия"
];
$fields =
[
'PRESET_ID' => 1,
'NAME' => 'Организация',
'ACTIVE' => 'Y',
'ENTITY_TYPE_ID' => '3',
'ENTITY_ID' => '144333',
'ADDRESS_ONLY' => "Y",
'RQ_ADDR' => $arRQAddr,
];
$requisite = new \Bitrix\Crm\EntityRequisite();
$res = $requisite->add($fields);
vmkfstools -i disk.vmdk -d zeroedthick disk1.vmdk
iptables -I INPUT -p tcp --match multiport --dport 8010:8015 -j ACCEPT
iptables -I INPUT -p tcp --match multiport --dport 9010:9011 -j ACCEPT
netstat -ntulp
upstream nodejs_sub {
ip_hash;
keepalive 1024;
server push:8010;
server push:8011;
server push:8012;
server push:8013;
server push:8014;
server push:8015;
}
upstream nodejs_pub {
ip_hash;
keepalive 1024;
server push:9010;
server push:9011;
}
location ~* ^/bitrix/subws/ {
access_log off;
proxy_pass http://nodejs_sub;
...
proxy_set_header Authorization "" ;
include bx/settings/rtc-im_settings.conf;
include bx/bx_general_proxy_settings.conf;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 8 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 10m;
gzip on;
gzip_proxied any;
gzip_static on;
gzip_http_version 1.0;
gzip_types application/x-javascript application/javascript text/css;
default_type application/force-download;
tcp_nopush on;
tcp_nodelay on;
client_max_body_size 1024m;
client_body_buffer_size 4m;
log_format simple '$time_local $status $request';
# if connection ti not set
map $http_upgrade $connection_upgrade {
default upgrade;
'' 'close';
}
map $http_upgrade $replace_upgrade {
default $http_upgrade;
'' "websocket";
server {
listen 80;
if ($host = {DNS name}) {
return 301 https://$host$request_uri;
} # managed by Certbot
}
server {
listen 443 ssl;
server_name {DNS name} www.{DNS name};
access_log /var/www/httpd-logs/{DNS name}.access.log;
error_log /var/www/httpd-logs/{DNS name}.error.log notice;
ssl_certificate /etc/letsencrypt/live/{DNS name}/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/{DNS name}.su/privkey.pem; # managed by Certbot
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_ignore_client_abort on;
proxy_pass https://{IP VM B24}:443;
proxy_redirect https://{IP VM B24}:443 /;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header HTTPS YES;
# for Push&Pull
location /bitrix/subws/ {
access_log off;
proxy_max_temp_file_size 0;
proxy_read_timeout 43800;
proxy_http_version 1.1;
proxy_pass https://{IP VM B24}:443;
proxy_set_header Upgrade $replace_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect https://{IP VM B24}:443 /;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header HTTPS YES;
}
location /bitrix/sub/ {
access_log off;
rewrite ^/bitrix/sub/(.*)$ /bitrix/subws/$1 break;
proxy_pass https://{IP VM B24}:443;
proxy_max_temp_file_size 0;
proxy_read_timeout 43800;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header HTTPS YES;
}
location /bitrix/rest/ {
access_log off;
proxy_pass https://{IP VM B24}:443;
proxy_max_temp_file_size 0;
proxy_read_timeout 43800;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header HTTPS YES;
}
}
nginx -s reload
nginx -t
systemctl restart nginx
set_real_ip_from {IP revers-proxy};
real_ip_header X-Forwarded-For;
du -hc --max-depth=1
zo0mik 10.08.17 16:06:53:
"Ну вот почему нельзя написать об этом во всех руководствах, что если не написать всего лишь одну эту строчку, то в каких-то случаях хоть голову о клаву разбей, оно может и не заработать вообще?!!! А вообще, желательно: client min protocol = NT1 client max protocol = SMB3 ntlm auth = yes create mask = 0664 directory mask = 0775 acl allow execute always = True и обязательно проверить наличие директории в локальной файловой системе и права на неё!"
[global]
#workgroup = WORKGROUP
security = user
map to guest = bad user
wins support = no
dns proxy = no
log level = 3
client min protocol = NT1
client max protocol = SMB3
ntlm auth = yes
acl allow execute always = True
log file = /var/log/samba/log.%m
[183]
path = /home/cams/captures/183
valid users = cams
guest ok = no
browsable = yes
writable = yes
read only = no
create mask = 0665
directory mask = 0775