Глава 38. Настройка за обратным прокси

Запросы к установленному PPEM можно проксировать на основании URL-префиксов.

При выполнении этой инструкции обратите внимание на следующие особенности:

  • в качестве примера обратного прокси используется nginx

  • в качестве примера URL-префикса используется /ppem

Чтобы настроить PPEM за обратным прокси:

  1. На сервере, на котором установлен nginx:

    1. В блоке http файла конфигурации nginx.conf укажите:

      map $http_upgrade $connection_upgrade {
         default upgrade;
         ''      close;
      }
    2. Настройте перенаправление на URL-префикс /ppem.

      Например, в /etc/nginx/sites-enabled/default укажите:

      server {
          listen 80 default_server;
          root /var/www/html;
          server_name _;
          location /ppem/ {
              rewrite  ^/ppem/(.*)/\$1 break;
              proxy_pass http://127.0.0.1:8080/;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection $connection_upgrade;
              proxy_set_header Host $http_host;
          }
          location / {
              return 404;
          }
      }
    3. Перезагрузите nginx:

      systemctl reload nginx

    За подробной информацией обратитесь к официальной документации nginx.

  2. На сервере, на котором установлен менеджер:

    1. В файле конфигурации менеджера ppem-manager.yml укажите:

      frontend:
        PPEM_API_PREFIX: /ppem
        PPEM_FRONTEND_BASENAME: /ppem
    2. В usr/share/ppem/web-app/index.html замените <base href="/" /> на <base href="/ppem/" />.

    3. Перезапустите PPEM:

      restart ppem
  3. На серверах, на которых установлены агенты:

    1. В файле конфигурации агента ppem-agent.yml добавьте URL-префикс /ppem к значению параметра agent.manager.url.

      Это значение указывается в формате схема://сетевой_адрес_менеджера/путь_к_версии_API. URL-префикс необходимо добавить между /сетевой_адрес_менеджера/ и /путь_к_версии_API.

      Например, если текущее значение — https://example.postgrespro.ru/v1, обновлённым значением должно быть https://example.postgrespro.ru/ppem/v1.

    2. Перезапустите агент:

      systemctl restart ppem-agent
  4. (Необязательно) Чтобы nginx мог загружать отчёты заданного размера, в директиве http, server или location укажите параметр client_max_body_size: размер_отчёта_в_МБ;.

    Например, в директиве server укажите:

    server {
            listen 80 default_server;
            root /var/www/html;
            server_name _;
            client_max_body_size 100M;
            ....
    }

    В этом случае максимальный размер отчёта — 100 МБ.

Chapter 38. Configuration Behind a Reverse Proxy

You can proxy requests to installed PPEM based on required URL prefixes.

When performing this instruction, consider the following:

  • nginx is used as a reverse proxy example

  • /ppem is used as a URL prefix example

To configure PPEM behind a reverse proxy:

  1. On the server where nginx is installed:

    1. In the http block of the nginx.conf configuration file, specify:

      map $http_upgrade $connection_upgrade {
         default upgrade;
         ''      close;
      }
      
    2. Configure redirection to the /ppem URL prefix.

      For example, in /etc/nginx/sites-enabled/default, specify:

      server {
          listen 80 default_server;
          root /var/www/html;
          server_name _;
          location /ppem/ {
              rewrite  ^/ppem/(.*)/\$1 break;
              proxy_pass http://127.0.0.1:8080/;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection $connection_upgrade;
              proxy_set_header Host $http_host;
          }
          location / {
              return 404;
          }
      }
      
    3. Reload nginx:

      systemctl reload nginx
      

    For more information, refer to the official nginx documentation.

  2. On the server where the manager is installed:

    1. In the ppem-manager.yml manager configuration file, specify:

      frontend:
        PPEM_API_PREFIX: /ppem
        PPEM_FRONTEND_BASENAME: /ppem
      
    2. In usr/share/ppem/web-app/index.html, replace <base href="/" /> with <base href="/ppem/" />.

    3. Restart PPEM:

      restart ppem
      
  3. On the servers where agents are installed:

    1. In the ppem-agent.yml agent configuration file, add the /ppem URL prefix to the agent.manager.url parameter value.

      This value is specified in the scheme://manager_network_address/path_to_API_version format. You must add the URL prefix between /manager_network_address/ and /path_to_API_version.

      For example, if the current value is https://example.postgrespro.com/v1, the updated value must be https://example.postgrespro.com/ppem/v1.

    2. Restart the agent:

      systemctl restart ppem-agent
      
  4. (Optional) To enable nginx to download reports of the required size, in the http, server, or location directive, specify the client_max_body_size: report_size_in_MBs; parameter.

    For example, in the server directive, specify:

    server {
            listen 80 default_server;
            root /var/www/html;
            server_name _;
            client_max_body_size 100M;
            ....
    }
    

    In this case, the maximum report size is 100 MB.

FAQ