Компилим nginx с модулем утянув его выше в папку из git https://github.com/wandenberg/nginx-push-stream-module
./configure --add-module=../nginx-push-stream-module
делаем общую include в /etc/nginx/conf.d/
push-stream-module
.conf
# Common settings for nginx-push-stream-module
push_stream_shared_memory_size 256M;
push_stream_max_messages_stored_per_channel 1000;
push_stream_max_channel_id_length 32;
push_stream_max_number_of_channels 200000;
push_stream_message_ttl 86400;
# поддержка мобильных платформ, для http запросов
server {
# nginx-push-stream-module server for push & pull
listen 8893;
server_name _;
# Include error handlers
#include bx/conf/errors.conf;
# Include im subscrider handlers
#include bx/conf/im_subscrider.conf;
location ^~ / { deny all; }
}
# поддержка мобильных платформ, для https запросов
# SSL enabled server for reading personal channels
server {
listen 8894 ssl;
server_name _;
ssl_certificate "/var/www/httpd-cert/www-root/example.com.crtca";
ssl_certificate_key "/var/www/httpd-cert/www-root/example.com.key";
#include bx/conf/ssl.conf;
# Include error handlers
#include bx/conf/errors.conf;
# Include im subscrider handlers
#include bx/conf/im_subscrider.conf;
location ^~ / { deny all; }
}
# для публикации сообщений
# Server to push messages to user channels
server {
listen 127.0.0.1:8895;
server_name _;
location ^~ /bitrix/pub/ {
push_stream_publisher admin;
push_stream_channels_path $arg_CHANNEL_ID;
push_stream_store_messages on;
allow 127.0.0.0/8;
deny all;
}
location ^~ / { deny all; }
# Include error handlers
#include bx/conf/errors.conf;
}
делаем инклюдку для server {}
include /etc/nginx/
push-stream-module
-vhost.inc
# Location for long-polling connections
location ^~ /bitrix/sub {
# we don't use callback and droppped it (XSS)
if ( $arg_callback ) {
return 400;
}
push_stream_subscriber long-polling;
push_stream_allowed_origins "*";
push_stream_channels_path $arg_CHANNEL_ID;
push_stream_last_received_message_tag $arg_tag;
if ($arg_time) {
push_stream_last_received_message_time "$arg_time";
}
push_stream_longpolling_connection_ttl 40;
push_stream_authorized_channels_only on;
push_stream_message_template '#!NGINXNMS!#{"id":~id~,"channel":"~channel~","tag":"~tag~","time":"~time~","eventid":"~event-id~","text":~text~}#!NGINXNME!#';
}
# Location for websocet connections
location ^~ /bitrix/subws/ {
push_stream_subscriber websocket;
push_stream_channels_path $arg_CHANNEL_ID;
push_stream_websocket_allow_publish off;
push_stream_ping_message_interval 40s;
push_stream_authorized_channels_only on;
push_stream_last_received_message_tag "$arg_tag";
push_stream_last_received_message_time "$arg_time";
push_stream_message_template '#!NGINXNMS!#{"id":~id~,"channel":"~channel~","tag":"~tag~","time":"~time~","eventid":"~event-id~","text":~text~}#!NGINXNME!#';
}
Включаем в битриксе
Оригинал https://dermanov.ru/exp/configure-push-and-pull-module-for-bitrix24/
Комментариев нет:
Отправить комментарий