Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
All solutions
    • All solutions for Application Load Balancer
    • Resolving the `no_route` error when accessing an address
    • Resolving issues when adding a route
    • How to retrieve the real IP address of the source in request headers

In this article:

  • Case description
  • Solution
  1. Application Load Balancer
  2. How to retrieve the real IP address of the source in request headers

How to get the real IP address of the source in request headers

Written by
Yandex Cloud
Updated at December 17, 2025
View in Markdown
  • Case description
  • Solution

Case descriptionCase description

You need to log external IP addresses of clients establishing connections with the load balancer.

SolutionSolution

When traffic is intercepted between clients and servers, the server access logs only contain the IP address of the proxy server or load balancer.

In Yandex Network Load Balancer, the IP address of the remote host initiating the request is visible by default without additional settings unless you use Ingress Controller for Kubernetes. If you are using it, follow this guide to manually set TrafficPolicy: local in order to preserve actual IP addresses for requests.

When you use Yandex Application Load Balancer, the request source IP address is listed in the X-Forwarded-For.
The X-Forwarded-For header identifies the origin of the IP address of the user connecting to the web server via an HTTP proxy or a load balancer.

To write external addresses in the web server log, change its configuration.

Nginx
Apache

If you are running an Nginx web server as a backend, make sure your Nginx service configuration has the http_x_forwarded_for variable in the log_format section:

log_format main '$remote_addr - $http_x_forwarded_for - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent "$http_referer" '
                '"$http_user_agent" $request_time';

If you are running an Apache web server as a backend, make sure your Apache service configuration has the %{X-Forwarded-For} variable:

Log format config

LogFormat "%{X-Forwarded-For}i %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" common
SetEnvIf X-Forwarded-For "^......." forwarded
CustomLog "logs/access_log" common env=forwarded

After changing the web server configuration and restarting it, you will see the external IP addresses of clients in your logs.
For example, if a request with IP 123.34.56.67 comes to Ingress:

kubectl logs nginx-ingress-nginx-ingress-*****
123.34.56.67 - - [28/Jun/2022:09:11:32 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/7.68.0" "-"

In the backend pod log, this address will be listed in the X-Forwarded-For header:

kubectl logs -n demo-ns pod/nginx
10.20.129.8 - - [28/Jun/2022:09:11:32 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/7.68.0" "123.34.56.67"

Was the article helpful?

Previous
Resolving issues when adding a route
Next
All solutions for Yandex Cloud Billing
© 2026 Direct Cursus Technology L.L.C.