Este producto no es compatible con el sitio Datadog seleccionado. ().

You can enable App and API Protection for PHP services with the following setup options:

  1. If your PHP service already has APM tracing set up and running, then skip to service configuration
  2. If your PHP service doesn't have APM tracing set up, you can easily enable App and API Protection with Datadog's Automatic Installation
  3. Otherwise, keep reading the following manual setup instructions

Overview

App and API Protection leverages the Datadog PHP library to monitor and secure your PHP service. The library integrates seamlessly with your existing application without requiring code changes.

For detailed compatibility information, including supported PHP versions, frameworks, and deployment environments, see PHP Compatibility Requirements.

This guide explains how to set up App and API Protection (AAP) for PHP applications. The setup involves:

  1. Installing the Datadog Agent
  2. Enabling App and API Protection monitoring
  3. Running your PHP application with the Datadog Agent
  4. Verifying the setup

Requisitos previos

  • Docker instalado en tu host
  • Aplicación PHP en contenedor con Docker
  • Tu clave de API Datadog
  • Biblioteca de rastreo PHP de Datadog (consulta requisitos de la versión)

1. Instalación del Datadog Agent

Instala el Datadog Agent siguiendo las instrucciones de instalación de Docker.

2. Activación de la monitorización de App and API Protection

Automatically enabling App and API Protection through Remote Configuration

You can enable services with remote configuration on your services dashboard. Check the box for the service you want to enable App and API Protection for under Activate on your APM services.

Activación manual de la monitorización de App and API Protection

Añade lo siguiente a su archivo Docker:

# Install dd-trace-php
RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php
RUN php datadog-setup.php --php-bin=all
# Enable appsec
ENV DD_APPSEC_ENABLED=true
# Configure your service
ENV DD_SERVICE=<YOUR_SERVICE_NAME>
ENV DD_ENV=<YOUR_ENVIRONMENT>

Para deshabilitar el rastreo APM mientras se mantiene App and API Protection activado, debes configurar la variable de rastreo de APM como false.

Añade lo siguiente a tu archivo Docker:

# Install dd-trace-php
RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php
RUN php datadog-setup.php --php-bin=all
# Enable appsec
ENV DD_APPSEC_ENABLED=true
# Disable apm
ENV DD_APM_TRACING_ENABLED=false
# Configure your service
ENV DD_SERVICE=<YOUR_SERVICE_NAME>
ENV DD_ENV=<YOUR_ENVIRONMENT>

3. Ejecutar tu aplicación

Crea tu imagen y luego ejecuta tu contenedor.

Cuando ejecutes tu contenedor, asegúrate de hacer lo siguiente:

  1. Conecta el contenedor a la misma red Docker que el Datadog Agent.
  2. Configura las variables de entorno necesarias.
docker run -d \
  --name your-php-app \
  your-php-app-image

4. Verify setup

To verify that App and API Protection is working correctly:

  1. Send some traffic to your application.
  2. Check for security signals and vulnerabilities in the Application Signals Explorer in Datadog.

Solucionar problemas

Si tienes problemas al configurar App and API Protection para tu aplicación PHP, consulta la Guía de solución de problemas de App and API Protection en PHP.

Referencias adicionales