---
- name: Install PHP-FPM
  hosts: vm-akazantsev
  roles:
    - php-fpm
    - nginx

  vars:
    php_enablerepo: "php:remi-8.2"
    php_enable_php_fpm: true
    php_enable_webserver: false
    php_webserver_daemon: "nginx"
    php_fpm_enabled_on_boot: true
    php_install_recommends: true
    php_fpm_pool_user: nginx
    php_fpm_pool_group: nginx
    php_executable: "php"
    php_fpm_pools:
      - pool_name: www
        pool_listen: "127.0.0.1:9000"
        pool_listen_allowed_clients: "127.0.0.1"
        pool_pm: dynamic
        pool_pm_max_children: 5
        pool_pm_start_servers: 2
        pool_pm_min_spare_servers: 1
        pool_pm_max_spare_servers: 3
        pool_pm_max_requests: 500
        pool_pm_status_path: /status

    nginx_selinux: false
    pki_dir: /etc/nginx/certs
    nginx_webroot: /var/www
    local_http_port: 80
    nginx_letsencrypt_managed: false
    letsencrypt_acme_install: false
    letsencrypt_acme_certs_dir: /etc/letsencrypt/live
    nginx_conf_snippets:
      - nginx-compression.conf
      - nginx-proxy-params.conf
      - nginx-server-ssl.conf
    #     - nginx-websockets.conf
    #     - nginx-browser-cache.conf
    #     - letsencrypt-proxy.conf
    #     - nginx-cors.conf

    nginx_virthosts:
      - virthost_name: test
        listen: "80"
        server_name: test.ru
        server_aliases: "www"
        root: "/var/www/test.ru"
        index: index.php
        # error_page: /path_to_error_page.html
        ssl_enabled: false
        ssl_only: false
        ssl_letsencrypt_certs: "{{ nginx_letsencrypt_managed }}"
        # root: "{{ nginx_webroot }}"
        server_tokens: "off"
        proxy_standard_setup: true
        proxy_additional_options:
          - proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache:30m max_size=250m;
        proxy_ips:
          - 10.203.2.21
          - 10.203.2.22
        locations:
          - location: ~ \.php$
            php_target: localhost:9000
         #   target: http://localhost:{{ local_http_port }}
        extra_parameters: |
          # map $sent_http_content_type $expires {
          # image/jpeg +3d;
          # image/gif +3d;
          # }
          location / {
          try_files $uri $uri/ /bitrix/urlrewrite.php$is_args$args;
          }

#          location ~ \.php$ {
#          fastcgi_split_path_info ^(.+\.php)(/.+)$;
#          fastcgi_pass unix:/var/run/php5-fpm.sock;
#          fastcgi_index index.php;
#          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#          include fastcgi_params;
#          }
