Question

Hosting a website on a DO droplet and Github Pages

Posted January 22, 2015 2.3k views

Is it possible to have a website hosted on two places (in my case here and github pages) so if one stop working I have the other as a fallback for minimal downtime? Like if I need to change something on my VPS and need it to be offline.

For exemple: If someone access example.com it firsts check to see if the DO one is online, if not, it redirects to the one hosted on github pages.

Do I need load balancing or is there anything easier to setup?

Did I make myself clear? If any other information is needed let me know.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

You would need an extra droplet or other server to act as a proxy/load balancer. You can set up a small droplet with nginx and configure it using a configuration like the one below:

upstream lb {
    server server1.com:80;
    server server2.com:80;
}

server {
    listen  80;
    server_name localhost;

  location / {
        proxy_pass              http://lb;
        proxy_redirect          off;
        proxy_next_upstream     error timeout invalid_header http_500;
        proxy_connect_timeout   2;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Submit an Answer