Install wordpress on amazon lightsail
Install wordpress on amazon lightsail
04/12/2016
Install free HTTPS SSL on wordpress with ubuntu
Install free HTTPS SSL on wordpress with ubuntu
24/02/2017
Show all

Install load balancer with nginx on ubuntu 14

Install load balancer with nginx on ubuntu 14

Create EC2 with Ubuntu 14 and:

sudo apt-get update
sudo apt-get install nginx

Backup default file
sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default-bk
sudo nano /etc/nginx/sites-available/default

Add this lines:

upstream backend {

        server IP1 ;
        server IP2 backup;
}

server {
    listen       80;
    server_name  test.com;
    return       301 http://www.test.com$request_uri;
}

server {
    listen       80;
    server_name  www.test.com;

        location / {
        proxy_pass http://backend/;
        }
}

sudo service nginx restart

example

DNS Server

a record www.your ngnix load balancer
a record *.your ngnix load balancer

go to Server 1

1.logon to phpmyadmin and set siteurl = http://www.your domain
2. sudo nano /opt/bitnami/apps/wordpress/htdocs/wp-config.php and disable all WP_SITEURL

example

go to Server 2

1.logon to phpmyadmin and set siteurl = http://www.your domain
2. sudo nano /opt/bitnami/apps/wordpress/htdocs/wp-config.php and disable all WP_SITEURL

example

 

Fix permalink
add . (dot ) to home url

Test server failure

sudo /opt/bitnami/ctlscript.sh stop apache
sudo service apache2 stop

Reference: https://www.yanivp.net//www.atlantic.net/community/howto/install-configure-nginx-load-balancer/

If the server is down

add down:

upstream backend {

server IP1 ;
server IP2 down;
}

Leave a Reply

Your email address will not be published. Required fields are marked *