Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Set Up Nginx Load Balancing With SSL Termination

A practical NGINX guide covering HTTPS termination, upstream pools, round-robin and least-connection balancing, HTTP or HTTPS backend traffic, certificate trust, troubleshooting, and production checks.
Length10 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure NGINX as the HTTPS edge, keep the public certificate and private key there, and place an upstream pool behind it. NGINX terminates the client TLS session on port 443, selects a backend, and forwards the request with proxy_pass. The second connection can be ordinary HTTP inside a trusted network or HTTPS when the hop to the application servers must also be encrypted.

This design gives one public endpoint while distributing requests across multiple application instances. It can improve resource utilization, throughput, latency, and fault tolerance, but only when certificate handling, forwarded headers, upstream trust, and operational checks are configured deliberately.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Understand the traffic flow before changing NGINX

A client resolves app.example.com to the address of NGINX and starts a TLS handshake on port 443. NGINX presents the certificate for that hostname, uses the private key to complete the handshake, decrypts the HTTP request, and chooses one server from the configured upstream group. NGINX then opens a separate connection to that server.

With proxy_pass http://app_backend;, the backend connection is plain HTTP. TLS protects the internet-facing leg only. With proxy_pass https://app_backend;, NGINX creates an encrypted connection to the selected backend as well. That is re-encryption, not reuse of the original client TLS session: there are two independent TLS sessions and NGINX is the endpoint of both.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

The F5 NGINX HTTP Load Balancing guide describes balancing across application instances as a way to optimize resource utilization, maximize throughput, reduce latency, and improve fault tolerance. Those are design goals, not guaranteed performance figures; the guides do not publish a universal throughput or latency improvement.

Prerequisites and a safe rollout plan

Confirm the NGINX build

Use a build that contains the HTTP SSL module. The open-source module reference notes that a source build may require --with-http_ssl_module. Check the running binary before deploying a configuration that uses listen 443 ssl:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
nginx -V 2>&1 | tr ' ' 'n' | grep http_ssl_module

Package names and service commands differ by operating system. Keep the existing configuration backed up and know how to restore it before making changes.

Prepare the backend applications

  • Give each application server a stable address and listening port, such as 10.0.0.11:8080 and 10.0.0.12:8080.
  • Permit connections from the NGINX host or its security group to those ports.
  • Make sure the application can interpret the original host, client address, and protocol from forwarded headers.
  • Decide whether sessions are stateless. If sessions are stored only in local memory, requests moving between servers may require persistence or a shared session store.

Obtain and protect the edge certificate

Obtain a certificate whose names cover the public hostname, along with its private key and any required intermediate certificates. A controlled internal environment can use an internally generated certificate, but public clients will normally need a certificate issued by a trusted certificate authority.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Store the certificate chain and key outside the web root. The certificate may be broadly readable by the NGINX master process, but the private key is sensitive. Use restrictive ownership and permissions, allow the NGINX master process to read it, and prevent unrelated users or services from reading it. Test permissions after every renewal or deployment; a correct path with an unreadable key causes NGINX to fail its configuration test or reload.

Build the basic HTTP-upstream configuration

The following pattern places an upstream pool and a client-facing HTTPS server in the http context of nginx.conf or an included file. Replace the addresses, hostname, and certificate paths with values for your environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
http {
    upstream app_backend {
        server 10.0.0.11:8080;
        server 10.0.0.12:8080;
    }

    server {
        listen 443 ssl;
        server_name app.example.com;

        ssl_certificate     /etc/nginx/tls/app.example.com/fullchain.pem;
        ssl_certificate_key /etc/nginx/tls/app.example.com/privkey.pem;
        ssl_protocols       TLSv1.2 TLSv1.3;

        location / {
            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 https;
            proxy_pass http://app_backend;
        }
    }
}

What each part does

Directive Purpose
upstream app_backend Names the backend pool. Each server line adds an address and port to that pool.
listen 443 ssl Accepts HTTPS on port 443 and enables TLS for this server block.
server_name Selects this virtual server for the requested hostname and participates in certificate/SNI selection.
ssl_certificate Points to the public certificate chain sent to clients.
ssl_certificate_key Points to the private key used for the public TLS session.
ssl_protocols Limits negotiated TLS versions to the explicitly listed protocols.
proxy_set_header Preserves the original host, client address, proxy chain, and HTTPS scheme for the application.
proxy_pass http://app_backend Sends the request to the named pool over HTTP. NGINX chooses a member using the pool’s balancing method.

Do not add a URI suffix to proxy_pass casually. A value such as proxy_pass http://app_backend; preserves the location’s request URI, while a value with a trailing path changes URI replacement behavior. Keep the simple form unless your application explicitly needs path rewriting.

Redirect port 80 to HTTPS

If the site should not serve application traffic over HTTP, add a separate listener that redirects clients:

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
server {
    listen 80;
    server_name app.example.com;
    return 301 https://$host$request_uri;
}

This redirect does not terminate TLS; it only moves an HTTP client to the HTTPS endpoint. Do not use it as a substitute for opening port 443 and installing a valid certificate.

Choose how NGINX distributes requests

Round robin is the default when no balancing directive is specified. NGINX sends successive requests across the listed servers, making it a sensible starting point when instances have similar capacity and requests take roughly similar time.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Method Configuration When it fits Important qualification
Round robin No extra directive Similar servers and broadly similar request duration It does not account for an individual request’s current cost.
Least connections least_conn; inside the upstream Requests have uneven duration or some clients hold connections open Connection count is only a proxy for work; a long-running request can still be more expensive than several short ones.
Least time Available in NGINX Plus Workloads where observed response time should influence selection Requires the Plus feature set.
Slow start and session persistence Available in NGINX Plus Warming a recovered server gradually or keeping a client tied to an instance Persistence can create uneven load and should not replace shared session storage when that is practical.

For least-connections balancing, the upstream begins like this:

upstream app_backend {
    least_conn;
    server 10.0.0.11:8080;
    server 10.0.0.12:8080;
}

Start with round robin, observe request duration and connection behavior, and switch only when the workload justifies it. The official guidance does not provide a numeric threshold at which one method universally wins.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Validate, reload, and verify the path

  1. Check syntax and referenced files. Run nginx -t. A successful result should report that the syntax is okay and the test is successful. Fix every error before reloading.
  2. Reload without dropping existing connections. Use the service manager appropriate to the host, commonly systemctl reload nginx, or send NGINX a reload signal through the host’s established operational procedure.
  3. Check the certificate externally. Connect to the public hostname and port 443 with a TLS-capable client, verify that the expected certificate chain is presented, and confirm that the negotiated protocol is allowed by your policy. Test the hostname, not merely the IP address, so SNI is exercised.
  4. Send an application request. Request a known endpoint through https://app.example.com/ and inspect the application logs for the expected host and forwarded protocol.
  5. Confirm both members receive traffic. Use distinct response headers or server logs temporarily, then send enough requests to observe the selected backends. This is an operational check, not a claim that a particular distribution is guaranteed for every client or connection pattern.
  6. Test failure behavior. Stop or isolate one backend in a controlled window, send requests, and verify that the remaining member responds as expected. Restore the member and confirm it can serve again before ending the test.

Re-encrypt the upstream connection with HTTPS

Use HTTPS on the second leg when traffic crosses an untrusted network, policy requires encryption in transit everywhere, or the backend itself must authenticate the proxy. Change the upstream target to https:// and configure certificate validation rather than disabling it.

http {
    upstream app_backend_tls {
        server app-1.internal.example:8443;
        server app-2.internal.example:8443;
    }

    server {
        listen 443 ssl;
        server_name app.example.com;

        ssl_certificate     /etc/nginx/tls/app.example.com/fullchain.pem;
        ssl_certificate_key /etc/nginx/tls/app.example.com/privkey.pem;
        ssl_protocols       TLSv1.2 TLSv1.3;

        location / {
            proxy_set_header Host app.internal.example;
            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 https;

            proxy_ssl_server_name on;
            proxy_ssl_name app.internal.example;
            proxy_ssl_trusted_certificate /etc/nginx/tls/internal-ca.pem;
            proxy_ssl_verify on;
            proxy_ssl_verify_depth 2;
            proxy_pass https://app_backend_tls;
        }
    }
}

Make upstream certificate validation match the design

  • proxy_ssl_trusted_certificate identifies the CA bundle NGINX should trust for backend certificates, including a private CA.
  • proxy_ssl_verify on makes NGINX reject an untrusted backend certificate instead of silently accepting it.
  • proxy_ssl_server_name on sends SNI to the backend. This matters when several certificates or virtual hosts share an address.
  • proxy_ssl_name supplies the name used for certificate verification and SNI. It must match the backend certificate’s intended name and trust model.

Do not “fix” an upstream certificate error by turning verification off. Install the correct CA chain, correct the backend name, or replace the backend certificate. If the backend requires mutual TLS, add a client certificate and key:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
proxy_ssl_certificate     /etc/nginx/tls/client-cert.pem;
proxy_ssl_certificate_key /etc/nginx/tls/client-key.pem;

Protect these client-key files with the same care as the public edge private key. Mutual TLS proves NGINX is an authorized client; it does not replace server-certificate validation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Forward the client identity safely

The example sets X-Real-IP, appends the existing chain to X-Forwarded-For, and declares the original scheme with X-Forwarded-Proto https. Configure the application framework to trust these headers only when they come from your NGINX address or an explicitly trusted proxy network. Otherwise, a direct attacker could submit forged forwarding headers.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Use $host rather than an unvalidated client-supplied value when preserving the public host. If the upstream virtual host is different from the public name, set Host to the backend name deliberately and document that mapping, as in the re-encryption example.

Tune TLS and protect key material

NGINX 1.23.4 and later document TLS 1.2 and TLS 1.3 as defaults. Older releases and distributions may differ, so explicitly review ssl_protocols during deployment. The example allows only TLS 1.2 and TLS 1.3; compatibility requirements may require a separate, documented decision.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Keep the private key readable by the NGINX master process and inaccessible to ordinary users.
  • Separate certificate renewal from key distribution, and re-run nginx -t after replacing either file.
  • Use the complete certificate chain where clients need intermediates.
  • Monitor certificate expiration and test renewal before the current certificate expires.
  • For upstream TLS, maintain the internal CA bundle and backend names as part of deployment configuration.

Support more than one HTTPS site with SNI

For several hostnames, create a server block for each site or use a carefully designed shared block. Each hostname needs a certificate whose names cover it. Modern clients send Server Name Indication (SNI), allowing NGINX to choose the matching certificate; clients that do not send the expected name can receive the default server’s certificate.

Keep the certificate and key directives with the server block that owns the hostname, and test each hostname separately. A certificate valid for one site does not automatically make another site’s TLS endpoint valid.

Common failures and precise fixes

Symptom Likely cause Fix
nginx -t reports an unknown ssl directive The build lacks the HTTP SSL module. Install a package or build that includes the module; source builds may need --with-http_ssl_module.
NGINX cannot load the certificate key Wrong path, malformed PEM, or restrictive permissions that exclude the master process. Check the file paths, PEM contents, ownership, and permissions, then run nginx -t again.
Clients see a certificate for another site Incorrect server_name, missing SNI from the test client, or the wrong default server. Test with the hostname, inspect the matching server blocks, and ensure the certificate covers that name.
502 Bad Gateway Backend is stopped, unreachable, listening on another port, or speaking a different protocol. Connect from the NGINX host to the backend address and port, inspect NGINX error logs, and ensure http:// versus https:// matches the service.
Upstream TLS verification fails Missing private CA, name mismatch, expired certificate, or absent SNI. Install the correct trusted CA, set proxy_ssl_name, enable SNI, and renew or replace the backend certificate.
The application records NGINX’s address as the client Forwarded headers are missing or the application does not trust the proxy. Set the forwarding headers and configure the application to trust only the NGINX network.
Requests appear stuck to one backend Long-lived keep-alive connections, a client-side connection pattern, persistence, or too little test traffic. Inspect connection and request logs, test with multiple clients, and choose a balancing method that matches request duration.
Reload fails after certificate renewal The new key is unreadable or the certificate and key do not match. Restore the previous valid pair, correct permissions or files, verify the pair, and reload only after nginx -t succeeds.

Open-source NGINX and NGINX Plus design choices

Open-source NGINX provides the basic reverse-proxy and load-balancing pattern shown here, including round robin and least-connections selection. NGINX Plus adds documented capabilities such as least time, slow-start, and session persistence. Select the edition based on the operational behavior you need rather than assuming a more advanced algorithm automatically improves every workload.

Regardless of edition, keep health and deployment procedures explicit. Verify that a failed instance is removed from useful service according to the behavior your edition and configuration provide, and perform controlled failure tests after changes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Production checklist

  • DNS points the public hostname to the NGINX edge.
  • Port 443 is reachable and the certificate names match the hostname.
  • The private key and any upstream client keys have restricted permissions.
  • The TLS protocol policy is explicit and reviewed for the installed NGINX version.
  • The upstream pool contains reachable application addresses and correct ports.
  • proxy_pass uses HTTP or HTTPS intentionally.
  • Forwarded headers are configured and trusted only from NGINX.
  • Upstream TLS validation uses the correct CA, name, and SNI settings.
  • nginx -t succeeds before every reload.
  • External handshake, application request, distribution, and backend-failure checks have been performed.
  • Certificate renewal, key rotation, log monitoring, and rollback procedures are documented.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.