4.9. 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.