Mastering Reverse Proxy with Nginx: Windows Load‑Balancing for IIS Sites
This article explains reverse proxy concepts, introduces Nginx’s core features and architecture, and provides a step‑by‑step guide to set up Nginx on Windows as a reverse‑proxy and load‑balancer for IIS‑hosted ASP.NET sites, including service registration, configuration tuning, static‑file caching, and testing.
Reverse Proxy: The Web Server’s Broker
Reverse proxy receives Internet requests, forwards them to internal servers, and returns the response, acting as a single external server.
Functions of Reverse Proxy
Protect website security by filtering all external requests.
Cache static resources to reduce backend load.
Implement load balancing across multiple servers.
Introducing Nginx
Nginx is a lightweight web server, reverse proxy and mail proxy known for stability, low resource consumption and high concurrency.
Key Features
Cross‑platform support.
Simple configuration.
Non‑blocking, high‑concurrency handling (up to 50 000 connections in tests).
Event‑driven architecture using epoll.
Master/Worker process model for fault isolation.
Low memory usage (≈15 MB per worker).
Built‑in health checks.
GZIP compression and bandwidth saving.
High stability for reverse‑proxy scenarios.
Practical Setup: Nginx + IIS Load Balancing on Windows
1. Prepare two ASP.NET sites on IIS
Create two identical ASP.NET applications, modify their Default.aspx to display “The First Web” and “The Second Web”, and assign ports 8050 and 8060.
2. Install Nginx for Windows
Download the Windows build (e.g., nginx‑1.4.7), extract it, and start it with start nginx.exe. Stop with nginx -s stop and reload with nginx -s reload.
3. Register Nginx as a Windows Service
Use “Windows Service Wrapper” (winsw) to wrap nginx.exe. Create an XML file (nginx-service.xml) with service definition:
<service>
<id>nginx</id>
<name>Nginx Service</name>
<description>High Performance Nginx Service</description>
<executable>D:\Servers
ginx-1.4.7
ginx.exe</executable>
<logpath>D:\Servers
ginx-1.4.7\</logpath>
<logmode>roll</logmode>
<startargument>-p D:\Servers
ginx-1.4.7</startargument>
<stopargument>-p D:\Servers
ginx-1.4.7 -s stop</stopargument>
</service>Install the service with nginx-service.exe install and set it to automatic start.
4. Basic nginx.conf configuration
Set worker_processes to the number of CPU cores.
Define listen 80; and appropriate server_name.
Configure a location block for ASP.NET pages and use proxy_pass http://backend; where backend lists the two IIS servers with weights.
5. Cache static resources
Add a location for static files, e.g.,
location /static/ { root /nginx-1.4.7/staticresources; expires 7d; }so images, CSS and JS are served directly from Nginx.
6. Test the load balancer
Access http://localhost/Default.aspx repeatedly; responses alternate between the two IIS instances, confirming round‑robin distribution.
Conclusion
The demo shows how Nginx can act as a reverse proxy and load balancer on Windows, providing security, caching, and high‑availability for IIS‑hosted applications, while laying a foundation for more advanced Linux‑based deployments.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
