I have a load balancer using Nginx from the Servers For Hackers tutorial site. This refers to two servers in a round robin setup. I have a self signed SSL
certificate in place to test an http
to https
redirect.
When I access the ip address of the load balancer, the request is only forwarding to the first ip address in the upstream app
block. I want it split to 50/50.
Looking at the configuration file, can someone tell me how to do this? These are all Amazon ec2 instances.
The redirect is working from http
to https
and the proxy is working to the first server.
upstream app {
server 172.31.33.5:80 weight=1;
server 172.31.42.208:80 weight=1;
}
server {
listen 80 default_server;
# Requests to /.well-known should look for local files
location /.well-known {
root /var/www/html;
try_files $uri $uri/ =404;
}
# All other requests get load-balanced
location / {
return 301 https://$http_host$request_uri;
}
}
server {
listen 443 ssl default_server;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 24h;
keepalive_timeout 300s;
ssl_certificate /etc/pki/tls/certs/load_balance.crt;
ssl_certificate_key /etc/pki/tls/certs/load_balance.key;
charset utf-8;
location / {
include proxy_params;
proxy_pass http://app;
proxy_redirect off;
# Handle Web Socket connections
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}