COMPUTER ENGINEER

Jump to examples
Blog
Next.js / ASP.NET Core / SQL6 min study
11/ 41

The edge

Reverse proxies, load balancers and TLS termination

The layer in front of your app: it decrypts, distributes and shields.

UnderstandStudy an examplePractise

Understand the concept

In production the application server is rarely exposed to the internet directly. A reverse proxy (Nginx, IIS, YARP, a cloud load balancer) stands in front. The proxy accepts the HTTPS connection and terminates TLS, centralising certificate management. It then forwards the request to one or more application instances on the private network.

A load balancer spreads incoming requests across healthy instances. It usually learns whether an instance is healthy by calling a health endpoint regularly (in this project /api/health). An unresponsive instance is removed from the pool, so the site stays up even if a server fails.

The proxy can also handle compression, request size limits, static files and basic attack filtering. There is a cost: the application now receives the request from the proxy rather than the client. The client’s real IP and scheme (https) travel in forwarded headers; reading them correctly and safely is the subject of the coming lessons.

WHEN TO USE IT

The IP, scheme and host your app sees depend on the proxy; security and logs depend on that.

COMMON PITFALL

Leaving the API and database ports open to the internet and using the proxy as decoration.

01 / PRACTICE

One topic. Three levels of depth.

Illustrative example
İnternet ──443──▶ [Ters vekil] ──5048 (iç ağ)──▶ API örneği 1
                                   └─────────────▶ API örneği 2

Only the proxy is visible from outside; app instances sit on the private network.

This page connects to no real server or database. Code samples are illustrative for .NET 8, Next.js and SQL Server; timings are example values in the simulation, not measurements. Try samples only in your own development environment; never share real connection strings, tokens or passwords.

02 / YOUR TURN

Try it yourself first.

Your health endpoint also checks the database. When the database is unreachable for 2 minutes every API instance leaves the pool and the whole site goes down. What do you change?

Show the solution and explanation
Worked solution
Canlılık (liveness) ile hazırlığı (readiness) ayır:
/health/live  → süreç ayakta mı (bağımlılık kontrolü yok)
/health/ready → bağımlılıklar hazır mı
Yük dengeleyici liveness’a bakar; ortak bir bağımlılık arızası bütün örnekleri öldürmez.

If a shared dependency failure marks every instance unhealthy, the balancer has nowhere to send traffic; serving cached data or an error page is better.