I am trying to set up a simple software load balancer based on NGINX for two IIS web servers. Here is the NGINX configuration file I have created for the load balancing:

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    # Definition von Load Balancing Cluster fur Share Point Farm

    upstream SPcluster {
        server weight=10 max_fails=3 fail_timeout=15;

        server weight=10 max_fails=3 fail_timeout=15;            

    server {
        location / {
           proxy_pass http://SPcluster;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  65;
    include /etc/nginx/conf.d/*.conf;


error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;

The problem is, that wen i try to access the IP of the load balancer through a web browser I get the following error:

Server Error in '/' Application.

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /SitePages/Homepage.aspx

What is wrong with my configuration? Why the nginx server tries to find the html files on the load balancer server and does not redirect the requests to the web servers that can actually server them?

  • Nginx's 404s don't look like that.
    – ceejayoz
    May 6, 2013 at 15:20

1 Answer 1


Try including this under your proxy_pass line:

 proxy_set_header Host $http_host;
  • A bit more background on why one would do this would improve your answer.
    – Dave M
    May 6, 2013 at 17:47
  • This directive works like a charm, the requests get to the IIS server now, but the authentication does not work for some reaseon, any idea why? And by authentication I mean user authentication with the IIS server with Windows accounts. Cheers, Konstantin May 7, 2013 at 7:55
  • @Dave: because the "supported" Load Balancer from Windows costs 90k USD :) May 7, 2013 at 8:10
  • If it works, then you may accept the answer :) Btw, could you post what is the error you get on the IIS servers and in the browser ? May 17, 2013 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.