Docker 환경에서 Ruby용 App 및 API Protection 설정
You can enable App and API Protection for Ruby services with the following setup options:
- If your Ruby service doesn't have APM tracing set up, you can easily enable App and API Protection with Datadog's Automatic Installation
- Otherwise, keep reading the following manual setup instructions
Overview
App and API Protection works by leveraging the Datadog Ruby library to monitor and secure your Ruby service. The library integrates seamlessly with your existing application without requiring code changes.
For detailed compatibility information, including supported Ruby versions, frameworks, and deployment environments, see Ruby Compatibility Requirements.
This guide explains how to set up App and API Protection (AAP) for Ruby applications. The setup involves:
- Installing the Datadog Agent
- Enabling App and API Protection monitoring
- Run Your Application
- Verifying the setup
사전 필수 조건
- 호스트에 설치된 Docker
- Docker로 컨테이너화된 Ruby 애플리케이션
- Datadog API 키
- Datadog Ruby 트레이싱 라이브러리(버전 요구 사항 참조)
1. Datadog Agent 설치하기
Docker 설정 지침에 따라 Datadog Agent를 설치합니다.
2. App 및 API Protection 모니터링을 활성화합니다.
Ruby 애플리케이션에서 datadog gem을 설치하고 구성합니다.
Gemfile에 datadog gem을 추가합니다.
이니셜라이저를 추가하여 Datadog 라이브러리 구성:
Datadog.configure do |c|
c.service = 'your_service_name'
c.env = Rails.env
c.tracing.enabled = true
# Rails 트레이싱 계측(instrumentation)은 명시적으로 활성화해야 합니다.
c.tracing.instrument :rails
c.appsec.enabled = true
c.appsec.api_security.enabled = true
#App 및 API Protection을 사용하려면 Rails 계측이 필요합니다.
c.appsec.instrument :rails
end
datadog gem을 Gemfile에 추가하고 자동 계측 필수 지정:
gem 'datadog', '~> 2.0', require: 'datadog/auto_instrument'
애플리케이션의 환경 변수를 설정하세요. 다음 항목을 Dockerfile에 추가합니다.
# Set environment variables
ENV DD_APPSEC_ENABLED=true
ENV DD_API_SECURITY_ENABLED=true
ENV DD_SERVICE=<YOUR_SERVICE_NAME>
ENV DD_AGENT_HOST=<YOUR_AGENT_HOST>
ENV DD_ENV=<YOUR_ENVIRONMENT>
App 및 API Protection을 활성화한 상태에서 APM 트레이싱을 비활성화하려면 APM 트레이싱 설정을 false로 지정해야 합니다.
Gemfile에 datadog gem을 추가합니다.
이니셜라이저를 추가하여 Datadog 라이브러리 구성:
Datadog.configure do |c|
c.service = 'your_service_name'
c.env = Rails.env
c.agent.host = 'your_agent_host'
# Disable APM Tracing
c.tracing.enabled = false
# Tracing instrumentation for Rails has to be explicitly enabled
c.tracing.instrument :rails
c.appsec.enabled = true
c.appsec.api_security.enabled = true
# Rails instrumentation is required for App and API Protection
c.appsec.instrument :rails
end
datadog gem을 Gemfile에 추가하고 자동 계측 필수 지정:
gem 'datadog', '~> 2.0', require: 'datadog/auto_instrument'
애플리케이션에 대한 환경 변수를 설정하세요. 다음 항목을 Dockerfile에 추가합니다.
ENV DD_APPSEC_ENABLED=true
ENV DD_API_SECURITY_ENABLED=true
ENV DD_APM_TRACING_ENABLED=false
ENV DD_SERVICE=<YOUR_SERVICE_NAME>
ENV DD_AGENT_HOST=<YOUR_AGENT_HOST>
ENV DD_ENV=<YOUR_ENVIRONMENT>
3. 애플리케이션 실행
이미지를 빌드한 다음 컨테이너를 실행합니다.
컨테이너를 실행할 때는 Datadog Agent와 동일한 Docker 네트워크에 연결되어 있는지 확인하고, 애플리케이션에서 올바른 Agent 호스트를 설정하세요.
4. 설정 확인
App 및 API Protection이 올바르게 작동하는지 확인하려면,
- 트래픽 일부를 애플리케이션에 전송합니다.
- Datadog에서 App 및 API Protection 서비스 인벤토리를 확인합니다.
- 서비를 찾은 다음 Coverage 열에서 App 및 API 보호가 활성화되어 있는지 확인합니다.
트러블슈팅
Ruby 애플리케이션에서 App 및 API Protection을 설정하는 중 문제가 발생하면 Ruby App 및 API Protection 문제 해결 가이드를 참고하세요.
참고 자료