Перейти к основному содержимому

Установка API-gateway

Цель выполнения

API-gateway выступает в роли граничного прокси-сервера и предоставляет единую точку входа для остальных модулей продукта CopyWala.

Установка API-gateway является опциональной и необходима, если планируется использование централизованного каталога резервных копий.

Внимание!

После установки PBR-Agent необходимо также обязательно установить:

Предусловия

Перед началом установки убедитесь, что выполнены следующие условия:

  1. Подготовлено окружение.
  2. Получен и доступен для установки дистрибутив Platform V SynGX / Nginx версии, соответствующей системным требованиям.

Последовательность действий

Выполните установку API-gateway одним из способов:

примечание

Официальная документация Platform V SynGX.

Установка из RPM-пакета

  1. Установите пакет syngx-{rpm_version}-{OS_version}.x86_64.rpm:

    sudo dnf install {component_name}-{component_version}-{OS_version}.x86_64.rpm
  2. Откройте файл конфигурации API-gateway:

    sudo vi /opt/syngx/conf/syngx.conf
  3. Заполните конфигурационные параметры.

    Пример корректного syngx.conf

    user syngx;
    worker_processes auto;
    worker_cpu_affinity auto;
    error_log /opt/syngx/logs/error.log crit;
    pid /opt/syngx/logs/syngx.pid;
    #load_module /opt/syngx/modules/ndk_http_module.so;
    #load_module /opt/syngx/modules/ngx_http_brotli_filter_module.so;
    #load_module /opt/syngx/modules/ngx_http_brotli_static_module.so;
    #load_module /opt/syngx/modules/ngx_http_js_module.so;
    #load_module /opt/syngx/modules/ngx_http_lua_module.so;
    #load_module /opt/syngx/modules/ngx_http_sslkeylog_module.so;
    #load_module /opt/syngx/modules/ngx_http_stream_server_traffic_status_module.so;
    #load_module /opt/syngx/modules/ngx_stream_js_module.so;
    #load_module /opt/syngx/modules/ngx_stream_lua_module.so;
    #load_module /opt/syngx/modules/ngx_stream_server_traffic_status_module.so;
    #load_module /opt/syngx/modules/ngx_http_set_misc_module.so;
    #load_module /opt/syngx/modules/ngx_hashicorp_vault_module.so;
    events {
    worker_connections 1024;
    }
    http {
    include /opt/syngx/conf.d/*.conf;
    client_body_buffer_size 16k;
    client_header_buffer_size 1k;
    client_max_body_size 16M;
    large_client_header_buffers 4 8k;
    access_log /opt/syngx/logs/access.log;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GSM-SHA-256:ECDHE-RSA-AES128-GCM-SHA256;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    server {
    listen 29000;
    server_name <DNS запись узла> <IP адрес узла>;
    location /api/agent-manager/ {
    proxy_pass http://{IP_ADDRESS}:29010;
    # Если будет включен TLS и mTLS:
    # proxy_ssl_certificate /opt/syngx/conf/cert.pem;
    # proxy_ssl_certificate_key /opt/syngx/conf/key.pem;
    # proxy_ssl_trusted_certificate /opt/syngx/conf/upstream_rootca.pem;
    }
    location /ws {
    proxy_pass http://{IP_ADDRESS}:29015;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_intercept_errors on;
    proxy_redirect off;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-NginX-Proxy true;
    proxy_ssl_session_reuse off;
    # Если будет включен TLS и mTLS:
    # proxy_ssl_certificate /opt/syngx/conf/cert.pem;
    # proxy_ssl_certificate_key /opt/syngx/conf/key.pem;
    # proxy_ssl_trusted_certificate /opt/syngx/conf/upstream_rootca.pem;
    }
    location /api/storage-manager/ {
    proxy_pass http://{IP_ADDRESS}:29030;
    # Если будет включен TLS и mTLS:
    # proxy_ssl_certificate /opt/syngx/conf/cert.pem;
    # proxy_ssl_certificate_key /opt/syngx/conf/key.pem;
    # proxy_ssl_trusted_certificate /opt/syngx/conf/upstream_rootca.pem;
    }
    location /api/task-manager/ {
    proxy_pass http://{IP_ADDRESS}:29020;
    # Если будет включен TLS и mTLS:
    # proxy_ssl_certificate /opt/syngx/conf/cert.pem;
    # proxy_ssl_certificate_key /opt/syngx/conf/key.pem;
    # proxy_ssl_trusted_certificate /opt/syngx/conf/upstream_rootca.pem;
    }
    }
    server {
    listen 29001;
    server_name <DNS запись узла> <IP адрес узла>;
    location /metrics {
    add_header Allow "GET, HEAD, OPTIONS" always;
    if ( $request_method !~ ^(GET|HEAD|OPTIONS)$ ) {
    return 405;
    }
    snx_http_extstatus_prometheus on;
    allow all;
    deny all;
    }
    location /metrics_json {
    add_header Allow "GET, HEAD, OPTIONS" always;
    if ( $request_method !~ ^(GET|HEAD|OPTIONS)$ ) {
    return 405;
    }
    snx_http_extstatus_json on;
    allow all;
    deny all;
    }
    }
    }
  4. После обновления конфигурационного файла перезапустите сервис: $ systemctl syngx -s reload

  5. Запустите сервис syngx.service:

    sudo systemctl start syngx.service

Автоматизированная установка с помощью Ansible

Сценарий описан в разделе Автоматизированная установка (с помощью Ansible).

Проверка результата

  1. Проверьте статус сервера: $ systemctl status syngx.service.

  2. Положительным результатом проверки будут являться успешные записи в логах с выводом status=0/SUCCESS:

    syngx.service - The SYNGX HTTP and reverse proxy server
       Loaded: loaded (/etc/systemd/system/syngx.service; enabled; vendor preset: disabled)
      Drop-In: /etc/systemd/system/syngx.service.d
               └─service.conf
       Active: active (running) since Mon 2025-06-30 07:21:15 UTC; 5s ago
      Process: 106 ExecStart=/usr/sbin/syngx (code=exited, status=0/SUCCESS)
      Process: 105 ExecStartPre=/bin/bash -c chown syngx.syngx /opt/syngx/conf/syngx.conf.current (code=exited, status=0/SUCCESS)
      Process: 103 ExecStartPre=/bin/bash -c /sbin/syngx -T > /opt/syngx/conf/syngx.conf.current (code=exited, status=0/SUCCESS)
      Process: 99 ExecStartPre=/bin/bash -c VARTIME=`cat /proc/uptime | cut -d . -f 1`; if [ $VARTIME -le 300 ] ; then sleep 2; fi (code=exited, status=0/SUCCESS)
      Process: 98 ExecStartPre=/usr/sbin/syngx -t (code=exited, status=0/SUCCESS)
     Main PID: 107 (syngx)
        Tasks: 5 (limit: 26213)
       Memory: 4.6M
       CGroups: <Позиция syngx в иерархии cgroups>
    Jun 30 07:21:15 syngx2 systemd[1]: Starting The SYNGX HTTP and reverse proxy server...
    Jun 30 07:21:15 syngx2 syngx[98]: syngx: the configuration file /opt/syngx/conf/syngx.conf syntax is ok
    Jun 30 07:21:15 syngx2 syngx[98]: syngx: configuration file /opt/syngx/conf/syngx.conf test is successful
    Jun 30 07:21:15 syngx2 bash[104]: syngx: the configuration file /opt/syngx/conf/syngx.conf syntax is ok
    Jun 30 07:21:15 syngx2 bash[104]: syngx: configuration file /opt/syngx/conf/syngx.conf test is successful
    Jun 30 07:21:15 syngx2 systemd[1]: Started The SYNGX HTTP and reverse proxy server.

Пример запроса для проверки корректной обработки Syngx:

$ curl -I http://<DNS запись узла>:29001/metrics

Положительный ответ:

HTTP/1.1 200 OK
Server: SynGX/3.0.2 (based on nginx-1.24.0)
Date: Tue, 01 Jul 2025 08:26:34 GMT
Content-Type: text/html
Content-Length: 278
Connection: close