Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 {
        ip_hash;
        server 172.22.1.134:80 weight=10 max_fails=3 fail_timeout=15;

        server 172.22.1.133:80 weight=10 max_fails=3 fail_timeout=15;            
        }

    server {
        listen 172.22.9.100:80;
        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?

share|improve this question
    
Nginx's 404s don't look like that. –  ceejayoz May 6 '13 at 15:20

1 Answer 1

Try including this under your proxy_pass line:

 proxy_set_header Host $http_host;
share|improve this answer
    
A bit more background on why one would do this would improve your answer. –  Dave M May 6 '13 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 –  Konstantin Boyanov May 7 '13 at 7:55
    
@Dave: because the "supported" Load Balancer from Windows costs 90k USD :) –  Konstantin Boyanov May 7 '13 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 ? –  Gabor Vincze May 17 '13 at 16:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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