Üstbilgileri ve İstemci IP’sini İletme
Vekillik sırasında Nginx’in istek üstbilgilerini nasıl yeniden yazdığını ve özgün istemci bilgilerini üst düzey uygulamalar için nasıl koruyacağınızı öğrenin.
Üstbilgileri ve İstemci IP’sini İletme, CoddyKit'te ücretsiz bir API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Why Headers Matter
When Nginx acts as a reverse proxy, the upstream server only sees a connection coming from Nginx, not the real client. Without extra configuration, the backend loses the visitor's original IP, host, and protocol.
To keep this information, Nginx must forward headers describing the original request.
The Default Host Header
By default Nginx may pass the upstream server's address as the Host header. Many apps rely on the original host for routing or building absolute URLs.
Set it explicitly so the backend sees what the client requested:
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
}Preserving the Real Client IP
The X-Real-IP header carries the original client's address so the backend can log or rate-limit by real visitor.
$remote_addrholds the connecting client's IP
proxy_set_header X-Real-IP $remote_addr;X-Forwarded-For Chain
X-Forwarded-For is a comma-separated chain of every proxy a request passed through. The variable $proxy_add_x_forwarded_for appends the current client to any existing value.
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;Forwarding the Protocol
If TLS terminates at Nginx, the backend speaks plain HTTP and cannot tell the original scheme. Send X-Forwarded-Proto so it can build correct https URLs and set secure cookies.
proxy_set_header X-Forwarded-Proto $scheme;Putting It Together
A standard reverse-proxy block bundles all four headers. This is the baseline you will reuse across nearly every project.
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}Reusing Header Config
Repeating the same headers in every location is error prone. Put them in an include file and pull it in wherever needed.
# /etc/nginx/proxy_headers.conf
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# in a server/location block:
include /etc/nginx/proxy_headers.conf;Trusting Forwarded Headers Safely
Clients can spoof X-Forwarded-For. Only trust it from known proxies. Use the real_ip module to set the true client IP from trusted upstreams.
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Forwarded-For;
real_ip_recursive on;Removing or Clearing Headers
You can strip a header by setting it to an empty string. This is useful to hide internal headers from upstream or to prevent leaking server identity.
proxy_set_header X-Powered-By "";
proxy_hide_header X-Powered-By;Passing Custom Headers
You can inject your own headers to give the backend extra context, such as a tag identifying which gateway handled the request.
proxy_set_header X-Gateway-Node "edge-1";
proxy_set_header X-Request-Start $msec;Verifying the Result
Test from a backend that echoes headers (or use an inspector endpoint). You should see X-Real-IP matching your machine and X-Forwarded-Proto matching the scheme you used.
curl -H "Host: example.com" http://localhost/headersQuick Check
Which Nginx variable appends the current client to an existing forwarding chain?
Recap
You learned how Nginx rewrites requests and how to keep client context intact:
Hostpreserves the requested domainX-Real-IPandX-Forwarded-Forcarry the client IPX-Forwarded-Protoreports the original scheme- Use
real_ipand trusted ranges to avoid spoofing
These headers are the foundation of a transparent, secure reverse proxy.
Sıkça Sorulan Sorular
“Üstbilgileri ve İstemci IP’sini İletme” dersi ücretsiz mi?
Evet — “Üstbilgileri ve İstemci IP’sini İletme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) kursu toplamda 4 dersten oluşur.
“Üstbilgileri ve İstemci IP’sini İletme” dersinde ne öğreneceğim?
Vekillik sırasında Nginx’in istek üstbilgilerini nasıl yeniden yazdığını ve özgün istemci bilgilerini üst düzey uygulamalar için nasıl koruyacağınızı öğrenin. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway), başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.
“Üstbilgileri ve İstemci IP’sini İletme” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) dersinde kod yazıp çalıştırabilir miyim?
Evet. Her API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Basit Ters Proxy Yapılandırma
- Üst Akış Sunucuları ve Yük Dengeleme
- Proxy Tamponlama ve Önbelleğe Alma
- Üstbilgileri ve İstemci IP’sini İletme