Put NGINX on the public HTTP/HTTPS ports and run Apache on a loopback or private address. In NGINX, a server block selects the hostname and a location block sends requests to Apache with proxy_pass. Forward the original host, client address, and scheme so Apache and the application generate correct links, redirects, logs, and security decisions.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
The procedure below covers a single Apache backend, URI-prefix mistakes, TLS termination, redirects, WebSockets, buffering, hardening, validation, and the failure symptoms that commonly appear after the first successful request.
As an Amazon Associate I earn from qualifying purchases.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →How the NGINX–Apache arrangement works
The request path is:
Client → NGINX :80 or :443 → Apache 127.0.0.1:8080 (or another private backend address)
NGINX is the public edge. It accepts the connection, chooses a virtual host using listen and server_name, sends the request to Apache, receives Apache’s response, and returns that response to the client. Apache remains the application-facing web server but does not need to be reachable from the public internet.
Use a loopback listener when both services run on one machine. If Apache is on another host, use a private network address and firewall rules that permit the NGINX host while denying unsolicited public access. The exact bind syntax and firewall service names differ by operating system.
#1 Best Overall
- [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
- [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
- [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
- [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
- [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Prerequisites and planning
Decide which service owns each responsibility before editing either configuration. NGINX should own the public DNS name, ports 80 and 443, certificates when TLS terminates at the edge, and the connection to clients. Apache should own the backend virtual host and application files. Record the backend address, backend port, public hostnames, certificate names, WebSocket paths, and any endpoints that stream rather than return a finite response.
Make sure the NGINX package includes the HTTP proxy module and that Apache is installed and able to serve the application without a proxy. Keep a rollback copy of each configuration. A syntactically valid configuration can still route a hostname to the wrong virtual host or expose an unintended backend, so plan a test URL and a way to inspect both services’ logs.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Prepare Apache as the upstream
Choose a private listener
Configure Apache to listen on the address and port that NGINX will use, such as 127.0.0.1:8080. Do not bind Apache to a public interface when NGINX is intended to be the only entry point. Confirm that the selected port is free and that Apache starts successfully before editing NGINX.
Match the public hostname
Apache should have a virtual host for the public name, for example example.com. NGINX will preserve that name in the upstream Host header. This matters when Apache uses name-based virtual hosts or when the application builds absolute URLs from the host.
Check Apache directly from the NGINX host
Before introducing the proxy, request a known page from Apache’s private listener from the NGINX machine. A successful response proves that the backend is running and reachable; a refused connection, timeout, or wrong virtual host must be fixed before proxy troubleshooting can be meaningful.
Test both the default backend response and a request carrying the intended host. If Apache serves several name-based sites, a request sent to the port without the expected host can appear healthy while still selecting the wrong site. The host-preserving proxy configuration must therefore be tested with the same hostname clients will use.
Install the minimum NGINX server block
Create a site configuration appropriate for your distribution and place this block in the package’s enabled-server configuration:
server {
listen 80;
server_name example.com www.example.com;
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 $scheme;
proxy_pass http://127.0.0.1:8080;
}
}
listen selects the local address and port. server_name matches the requested host. The location / block handles every path not matched by a more specific location. proxy_pass identifies Apache as the upstream server.
Rank #2
- 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
- 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
- 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
- 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
- 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
NGINX modifies some proxied headers by default, including Host and Connection. Set the headers your backend requires instead of relying on defaults. The configuration above keeps the public host, records the immediate client address, appends the address to the forwarding chain, and communicates whether the client used HTTP or HTTPS.
The location is deliberately broad for a first deployment. Add narrower locations only when an endpoint needs different behavior, such as WebSocket upgrades or disabled buffering. A more specific location can change which proxy directives apply, so test routing after every new location.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Understand proxy_pass path behavior
The URI portion of proxy_pass determines whether NGINX preserves the incoming path or replaces the part matched by location. This is the most common cause of an application receiving an unexpected URL.
| NGINX configuration | Request | Typical upstream path | Use when |
|---|---|---|---|
location / { proxy_pass http://127.0.0.1:8080; } |
/images/logo.png |
/images/logo.png |
Apache should receive the original URI. |
location /app/ { proxy_pass http://127.0.0.1:8080/; } |
/app/index.php |
/index.php |
The public /app/ prefix should be removed. |
location /app/ { proxy_pass http://127.0.0.1:8080/app/; } |
/app/index.php |
/app/index.php |
The backend should retain an /app/ prefix. |
With no URI suffix, NGINX generally passes the original or normalized request URI. When a URI suffix is present, NGINX replaces the portion that matched the location. The trailing slash is therefore significant. Test a known URL through the public hostname and inspect Apache’s access log before deploying a prefix mapping.
Check edge cases such as /app without a trailing slash, encoded characters, query strings, and redirects generated by the application. A path mapping that looks correct for one file can still produce an incorrect redirect or asset URL. Keep the mapping simple unless the backend explicitly requires a prefix transformation.
Configure Apache’s virtual host for proxied requests
Apache’s virtual host must listen on the same address and port used in proxy_pass. Keep the public hostname in the ServerName or name-based virtual-host configuration so the preserved Host header selects the intended site.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsIf Apache or the application emits a redirect containing 127.0.0.1, an internal hostname, or the backend port, inspect the redirect’s Location header and the application’s base-URL settings. A reverse proxy must make redirects point to the public URL, not to its private upstream.
Apache’s reverse-proxy documentation notes that ProxyPassReverse is commonly required when Apache itself is acting as a reverse proxy so backend Location headers point back through that proxy. In an NGINX-fronted design, NGINX is the reverse proxy; apply the same principle by correcting the application’s public URL and forwarded-scheme trust rather than adding Apache directives that do not match your topology.
Rank #3
- [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
- [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
- [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
- [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
- [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
Forward host, client identity, and original scheme deliberately
Host
Use proxy_set_header Host $host; when Apache’s virtual-host selection or the application’s URL generation depends on the public hostname. If you need the original port as well, account for it in the application’s proxy settings rather than assuming the backend port is public.
X-Real-IP and X-Forwarded-For
X-Real-IP carries the immediate client address. X-Forwarded-For appends that address to an existing chain, preserving earlier trusted proxies. Configure Apache logs and the application framework to read these headers only from your controlled NGINX path. If clients can connect directly to Apache and submit arbitrary forwarding headers, they can spoof the recorded address.
Free tools Windows power users keep installed
One-click scans. No signup required.
X-Forwarded-Proto
When TLS ends at NGINX, Apache receives an ordinary HTTP connection unless you use HTTPS upstream. Forward X-Forwarded-Proto $scheme and configure the application to trust NGINX. Without that trust, an HTTPS page can generate HTTP redirects, insecure absolute links, or redirect loops.
Forwarded headers describe the client-to-edge connection, not a guarantee supplied by an untrusted caller. Restrict direct access to Apache, and configure the application’s trusted-proxy list to include only the NGINX address or private range. If another proxy is added later, document the order of the chain and update the trust boundary deliberately.
Choose where TLS terminates
| Design | Connection from client to NGINX | Connection from NGINX to Apache | When it fits |
|---|---|---|---|
| Edge termination | HTTPS on NGINX | HTTP on a loopback or private network | The backend network is trusted and certificate handling is centralized at NGINX. |
| End-to-end encryption | HTTPS on NGINX | HTTPS to Apache | Policy, compliance, or network boundaries require encryption on the internal hop. |
| HTTP only | HTTP on NGINX | HTTP to Apache | Suitable only where the service is intentionally non-TLS; it does not protect traffic in transit. |
NGINX accepts both http and https upstream protocols. Select the arrangement according to network trust and compliance requirements. If NGINX terminates TLS, place certificates and the public listen 443 ssl server block there, then ensure the forwarded scheme is trusted by Apache and the application.
Edge termination simplifies certificate management because clients connect to one public TLS endpoint. It does not encrypt the internal hop, so it is appropriate only when the loopback or private network is trusted for the deployment. HTTPS upstream adds certificate and hostname-validation work but protects traffic across a less-trusted internal boundary. The cited NGINX documentation supports both protocols without prescribing one universal policy.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallRedirect HTTP to the canonical HTTPS host
Use a separate port-80 server block that redirects to the canonical HTTPS hostname, and a TLS-enabled block that contains the proxy:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
# Configure the certificate directives required by your NGINX package here.
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 $scheme;
proxy_pass http://127.0.0.1:8080;
}
}
After TLS termination, verify that Apache does not issue a second HTTP-to-HTTPS redirect. If it does, the forwarded scheme is missing, or the application has not been configured to trust NGINX.
Rank #4
- Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
- Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
- All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
- Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
- Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Choose one canonical hostname and make both the redirect target and the TLS virtual host agree. Test requests to each alternate name, because a default NGINX server block or an Apache virtual host can otherwise answer with an unexpected certificate or redirect destination.
Support WebSockets and other upgraded connections
WebSocket proxying requires special upgrade handling and a compatible HTTP version; the ordinary HTTP example is not sufficient. A common pattern is to define a connection-upgrade map at the NGINX HTTP level and pass the resulting headers in the WebSocket location:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name example.com;
location /socket/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8080;
}
}
Use the actual WebSocket path exposed by the application. Test the handshake and a sustained connection, not just the initial HTTP status. Other protocols that rely on connection upgrades need their own compatibility checks.
Place the map in the HTTP-level configuration rather than inside a server or location block. Keep the upgraded location as narrow as possible, and verify that a broader location is not intercepting the endpoint first. A successful handshake followed by an immediate disconnect usually requires checking the application endpoint and the complete upgrade header chain, not only the initial status.
Decide how response buffering should behave
NGINX buffers proxied responses by default. Buffering can protect throughput when clients are slow, because Apache can finish producing a response without remaining tied to each client connection. Streaming endpoints, event feeds, and some long-lived responses may require proxy_buffering off; or other tuning.
Do not disable buffering globally without measuring. Apply a change to the narrowest location that needs streaming, then test memory use, latency, disconnect behavior, and Apache worker pressure under representative traffic.
Compare a finite HTML or file response with a streaming endpoint during testing. Inspect when bytes become visible to the client, how the connection behaves when the client is slow, and whether Apache workers remain occupied. The appropriate setting depends on endpoint behavior; a change that helps an event stream can reduce the protection buffering provides to ordinary requests.
Protect the backend and the proxy boundary
- Allow public access to NGINX, not to Apache’s loopback or private listener.
- Restrict the backend firewall rule to the NGINX host or private network.
- Trust
X-Forwarded-For,X-Real-IP, andX-Forwarded-Protoonly from proxies you control. - Keep the public and backend hostnames distinct in your operational documentation so an internal address is not accidentally published in redirects.
- Review access and error logs on both services; a client address shown by Apache is meaningful only when the trust boundary is correct.
Do not treat a private listener as a substitute for access control when Apache is on a shared network. The listener, firewall, and application trust settings should all agree about which machine is the proxy. If Apache must be reachable by more than one trusted NGINX host, allow that private set explicitly instead of opening the backend port broadly.
Best Value
Validate the configuration before exposing it
- Confirm Apache answers on its private listener from the NGINX host.
- Check that DNS for the requested hostname points to the NGINX machine and that
server_namematches it. - Run the NGINX package’s configuration test before reloading. On installations that provide the standard command, this is commonly
nginx -t. - Reload NGINX using the service manager supplied by your operating system. Do not restart blindly when a graceful reload is available.
- Request a known URL through the public hostname and record the status code, response body, and timing.
- Inspect the response’s
Locationheader for an internal host, wrong scheme, wrong port, or an unwanted path prefix. - Check Apache’s access log for the expected host, URI, and forwarded client address.
- Test static files, an application POST, a large response, an authentication flow, redirects, and every WebSocket endpoint.
- When a request fails, compare NGINX access and error logs with Apache’s logs at the same timestamp.
Test from both the NGINX host and an external client. A backend request can succeed while DNS, a firewall, a certificate, or a default public virtual host is still wrong. Include query strings and non-GET methods in the test set, because a simple browser request does not prove that POST handling or application redirects work.
Troubleshoot by symptom
| Symptom | Likely cause | What to inspect |
|---|---|---|
| 502 Bad Gateway | Apache is stopped, listening elsewhere, or blocked by a firewall. | Backend listener address, port, process status, and connectivity from the NGINX host. |
| Apache serves the wrong site | The upstream receives an unexpected or missing host. | proxy_set_header Host $host; and Apache name-based virtual-host matching. |
| Redirect points to 127.0.0.1 or an internal port | The application believes its public base URL is the backend URL. | The Location header, application base URL, and host/scheme proxy trust. |
| HTTPS redirects loop | Apache or the application sees HTTP after TLS ended at NGINX. | X-Forwarded-Proto and the application’s trusted-proxy configuration. |
| Every URL gains or loses a path prefix | The URI suffix on proxy_pass does not match the location design. |
Trailing slashes, the matched location, and Apache’s logged request path. |
| Logs show NGINX’s address instead of the client | Forwarded headers are absent or Apache is not configured to consume them. | X-Real-IP, X-Forwarded-For, and trusted proxy settings. |
| WebSocket handshake fails | Upgrade headers or HTTP/1.1 are missing, or the path is proxied by the wrong location. | Upgrade, Connection, proxy_http_version 1.1, and the endpoint path. |
| Streaming response stalls | Default proxy buffering is delaying delivery. | Endpoint behavior, buffering settings, and resource usage before changing them. |
| Requests time out | Backend work exceeds proxy limits, the upstream is overloaded, or network access is unreliable. | Both services’ timestamps, upstream reachability, application duration, and timeout settings. |
Correlate timestamps rather than diagnosing from one log alone. A 502 generally indicates that NGINX could not obtain a usable upstream response, while an application-generated 4xx or 5xx can prove that Apache was reached. The status alone is not enough: inspect the NGINX error log, Apache access and error logs, and the response headers together.
Recommended Free Tools
Choose the design deliberately
| Decision | Option A | Option B | Question to answer |
|---|---|---|---|
| TLS placement | Terminate at NGINX | Use HTTPS to Apache too | Does the internal network require encryption or certificate validation? |
| URI mapping | Preserve the original path | Replace a location prefix | What path does Apache and the application actually serve? |
| Backend exposure | Loopback-only listener | Private-network service | Which hosts must reach Apache, and what firewall rule enforces that? |
| Traffic behavior | Default buffering | Streaming-oriented settings | Does the endpoint stream or produce ordinary finite responses? |
| Application protocol | Regular HTTP | WebSocket or another upgrade protocol | Which locations need special connection handling? |
There is no single correct combination for every deployment. A single-host site often uses loopback Apache, TLS termination at NGINX, preserved paths, and default buffering. A segmented environment may use HTTPS upstream and a private firewall rule. Decide from the network boundary and application behavior, then encode the decision in configuration comments and operational documentation.
Production checklist
- NGINX owns the public ports and Apache is private.
- The correct
server_namereceives the hostname. proxy_passis inside the intendedlocationand its trailing slash behavior has been tested.- Host, client-address, forwarding-chain, and original-scheme headers are explicit.
- Apache and the application trust forwarded headers only from NGINX.
- The TLS termination point is documented and redirect behavior is verified.
- WebSocket locations include upgrade handling where required.
- Buffering changes are limited to endpoints that need them.
- Configuration testing, graceful reload, known-URL checks, and log correlation are part of every change.
This arrangement gives NGINX responsibility for the public connection while Apache continues to serve the backend application. Correct host and scheme forwarding, intentional URI mapping, private backend exposure, and post-change testing are what turn a basic proxy block into a dependable deployment.
Frequently Asked Questions
What should proxy_pass point to?
Point it to the address and port where Apache listens, such as http://127.0.0.1:8080 or an HTTPS private address when the internal hop is encrypted. Keep Apache’s listener private and verify reachability from the NGINX host first.
Why does the trailing slash in proxy_pass matter?
Without a URI suffix, NGINX generally forwards the original or normalized request URI. With a suffix, it replaces the portion matched by the location. Therefore /app/ mapped to a backend ending in / removes the public prefix, while a backend ending in /app/ retains it.
Why does Apache generate HTTP redirects when users connect with HTTPS?
TLS may terminate at NGINX, so Apache receives HTTP. Forward X-Forwarded-Proto $scheme and configure the application to trust NGINX; otherwise the application cannot reliably determine the original scheme and may create insecure links or redirect loops.
How do I preserve the real client IP?
Send X-Real-IP $remote_addr and X-Forwarded-For $proxy_add_x_forwarded_for. Configure Apache and the application to consume those headers only from the controlled NGINX address or private range. Direct public access to Apache would let clients spoof them.
Do WebSockets work with the basic reverse-proxy block?
Not necessarily. WebSockets require upgrade headers and a compatible HTTP version. Use a dedicated location with proxy_http_version 1.1, Upgrade, and an appropriate Connection value, then test both the handshake and a sustained connection.
Should I disable proxy buffering?
NGINX buffers proxied responses by default. Leave buffering enabled for ordinary finite responses unless measurement shows a problem. For streaming or long-lived endpoints, disable or tune buffering only in the narrow location that needs it, and observe memory, latency, disconnects, and Apache worker usage.
The Bottom Line
Run NGINX as the public listener, keep Apache on a loopback or private address, and make proxy_pass path behavior intentional. Explicit host, client-IP, and scheme headers—combined with correct TLS, redirect, WebSocket, buffering, firewall, and log checks—are the difference between a proxy that merely answers and one that remains dependable in production.
Quick Recap
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.

