By cihatturan
Hey there. I’m new at NGINX. I’ve a problem about Load Balancing for my local websites. I create three servers on different three Ubuntu 16.04 core servers.
I need to configure this 3 servers for, when client try to reach “https://tac.local” from browser, load balancer take the request and make Load balance between my two webserver. I can use round robin type btw.
Here my config files;
upstream backend {
server 192.168.56.8;
server 192.168.56.12;
server 192.168.56.13;
}
server {
listen 80;
listen 443 ssl;
server_name tac.local;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
listen [::]:80;
server_name $host;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name tac.local;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
root /var/www/$host/public;
index index.php index.html index.htm index.nginx-debian.html;
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
When i try to reach “https://tac.local” from Chrome, it’s saying; This page isn’t working tac.local redirected you too many times. Try clearing your cookies. ERR_TOO_MANY_REDIRECTS
Can you help me please?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
I would recommend trying to add the following right after the opening php tag in your wp-config.php file:
if ( 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = '443';
}
Then clear the cache of your browser and test it again.
Let me know how it goes. Regards, Bobby
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.