Blog · WebJi® India

Nginx Reverse Proxy in Front of Apache: Best of Both

Quick answer: Nginx Reverse Proxy in Front of Apache: Best of Both from WebJi®, billed in INR with 18% GST on the invoice. Email support@webji.services is 24/7 in Hindi and English (average first reply under 60 minutes). Phone +91 141 4941811 is business hours only. The company has been in this business since 2005.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Sealed cardboard moving boxes with a laptop in an office hallway, symbolising website migration — nginx reverse proxy apache

Why Combine Nginx and Apache

Four moves: move Apache to a private port, proxy Nginx in front, forward real IPs, serve statics directly.

  1. Apache to 127.0.0.1:8080 — edit ports.conf: Listen 127.0.0.1:8080; same for the virtualhost's VirtualHost line.
  2. Nginx server block — listen 80; server_name yoursite.com; location / { proxy_pass http://127.0.0.1:8080; } plus websocket and timeout lines.
  3. Forward real IPs — the X-Forwarded-For/X-Forwarded-Host headers, and Apache's mod_remoteip so logs and analytics stay truthful.
  4. Static direct — a location block for images/CSS/JS served by Nginx before the proxy sees them.
  5. TLS — Nginx owns 443 and terminates certificates; Apache never sees the internet.

The result: Apache keeps .htaccess compatibility while Nginx absorbs concurrency. The why and the port map are below. This stack runs on any VPS server plan; hosted alternatives sit on LiteSpeed hosting.

Architecture: Who Listens on Which Port

The architecture, port by port: Nginx owns the public interfaces — 80 (redirecting to 443) and 443 (TLS termination, the real entry point) — while Apache retreats to 127.0.0.1:8080, reachable only from the machine itself. Every browser request hits Nginx first: static assets are answered immediately from disk; dynamic requests proxy_pass to Apache, which still runs mod_php or PHP-FPM with its .htaccess rules intact.

The division earns its complexity: Nginx's event model absorbs thousands of concurrent connections with modest memory, while Apache keeps its ecosystem compatibility. The failure mode to know: Apache restarting onto port 80 because a config reverts — the reason ports.conf edits belong in configuration management, not memory.

Sealed cardboard moving boxes with a laptop in an office hallway, symbolising website migration — nginx reverse proxy apache

Step 1: Move Apache to 127.0.0.1:8080

How this plays out with proxy_pass directive: settings that look cosmetic usually decide page speed and uptime under real traffic. The defaults WebJi® ships are tuned for Indian network conditions, and support can review your setup on request.

Step 2: Nginx server Block With proxy_pass

Nginx server Block With proxy_pass. Do this on one site or a staging copy first, then check the public URL in a private window so cache does not hide the result. Stop if the page errors, and email support@webji.services with the step name and the exact error before you repeat it on every account. WebJi® support mail is staffed 24/7 in Hindi and English; the phone line +91 141 4941811 is business hours only.

Step 3: Forward Real IPs and Headers

On mod_proxy awareness, the honest summary is that defaults matter more than brand names — a well-set budget plan outranks a mis-tuned premium one. WebJi® documents its defaults openly and adjusts them per ticket when workloads need it.

Step 4: Static Files Directly via Nginx

Static Files Directly via Nginx. Do this on one site or a staging copy first, then check the public URL in a private window so cache does not hide the result. Stop if the page errors, and email support@webji.services with the step name and the exact error before you repeat it on every account. WebJi® support mail is staffed 24/7 in Hindi and English; the phone line +91 141 4941811 is business hours only.

Testing, Logs and Common Pitfalls

Testing, Logs and Common Pitfalls. Do the change this heading names on one site first, then check it in a private browser window or in the mail client, depending on the topic. Change one setting at a time, and undo it if the result is wrong before you try the next. If you want the Jaipur desk to look with you, email support@webji.services — that mailbox is staffed 24/7 in Hindi and English. Phone +91 141 4941811 is business hours only.

Frequently Asked Questions

How do I set up Nginx as a reverse proxy for Apache?

Four moves: move Apache to a private port, proxy Nginx in front, forward real IPs, serve statics directly.

Why put Nginx in front of Apache?

Four moves: move Apache to a private port, proxy Nginx in front, forward real IPs, serve statics directly. The question here is: Why put Nginx in front of Apache.

Does .htaccess still work behind an Nginx proxy?

For “Does .htaccess still work behind an Nginx proxy”: The architecture, port by port: Nginx owns the public interfaces — 80 (redirecting to 443) and 443 (TLS termination, the real entry point) — while Apache retreats to 127.0.0.1:8080, reachable only from the machine itself. Every browser request hits Nginx first: static assets are answered immediately from disk; dynamic requests proxy_pass to Apache, which still runs mod_php or PHP-FPM with its .htaccess rules intact.

What does the proxy_pass directive do?

How this plays out with proxy_pass directive: settings that look cosmetic usually decide page speed and uptime under real traffic. The defaults WebJi® ships are tuned for Indian network conditions, and support can review your setup on request.

How do I pass real visitor IPs to Apache?

Four moves: move Apache to a private port, proxy Nginx in front, forward real IPs, serve statics directly. The question here is: How do I pass real visitor IPs to Apache.

Which server should handle PHP requests?

The architecture, port by port: Nginx owns the public interfaces — 80 (redirecting to 443) and 443 (TLS termination, the real entry point) — while Apache retreats to 127.0.0.1:8080, reachable only from the machine itself. Every browser request hits Nginx first: static assets are answered immediately from disk; dynamic requests proxy_pass to Apache, which still runs mod_php or PHP-FPM with its .htaccess rules intact.

Is WebJi® an Indian company?

Yes. WebJi® is headquartered in Jaipur, Rajasthan and has operated since 2005. Billing, support and governance all run from India.

Do you provide GST invoices?

Every purchase and renewal gets a GST invoice with our GSTIN, and hosting prices are quoted exclusive of 18% GST. Claim input credit as applicable.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →