Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to setup nginx 0.6.33 on Fedora 8 as a load balancer for backends running Apache. I had no problems to configure it for default http port 80, but I don't know how to do it for SSL (443). I don't want to install the SSL certificates on the nginx box, I'd like it to pass the whole traffic through to the Apache servers which have the certificates already installed.

My configuration looks like this:

http {
  upstream backend{
    server 192.168.0.1;
    server 192.168.0.2;
  }

  upstream secure{
    server 192.168.0.1:443;
    server 192.168.0.2:443;
  }

  server{
    listen 80;
    server_name www.my-server.net;
    location / {
      proxy_pass http://backend;
      proxy_set_header Host $http_host;
      proxy_redirect false;
    }
  }

  server{
    listen 443;
    server_name www.my-server.net;
    location / {
      proxy_pass https://secure;
      proxy_set_header Host $http_host;
      proxy_redirect false;
    }
  }
}
share|improve this question
up vote 1 down vote accepted

Don't use nginx as a load balancer; it isn't designed for that sort of thing. Specifically, in your case, it doesn't support transparently passing TCP connections to a backend, so you'll need to have your SSL certs setup in nginx and pass back to Apache as regular HTTP.

You want either a true L3 load balancer like LVS, or else a TCP proxy like haproxy, that will allow the SSL connections to just flow straight through to Apache.

share|improve this answer
    
Since this answer is now ~5 years past (and was likely perfectly acceptable at the time), Nginx does support and make use of load balancing and might make for a different answer now. This answer came up as a high hit for a Google search I did, so I'm providing the reference link to preserve the answer's usefulness. link from Nginx.org: http://nginx.org/en/docs/http/load_balancing.html – Eric McCormick Aug 27 '15 at 15:06
    
Nginx supported load balancing at the time I wrote my answer, too. It still isn't a good solution for a load balancer, in comparison to the other available options. – womble Aug 27 '15 at 20:36

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.