M
M
mydev2018-05-21 10:07:22
linux
mydev, 2018-05-21 10:07:22

Site on home server and VPS at the same time. How to set up such a link?

There is an idea to place the site on a home hosting. I want to set up the system in such a way that in case of problems on the home server, all requests are sent to a copy of the site on the VPS server. The remote server will be a backup server at the same time. The home computer and the server will be synchronized every day. I'm going to use nginx.

Is such a scheme possible?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Cheremisin, 2018-05-21
@mydev

Yes, you can. On the hosting, you set up nginx, which sends all requests to the home server, and in case of problems, redirects to the local one on the VPS.
In the example below, all requests will go to my_home_ip_address, after three errors there will be a redirect to 127.0.0.1:8080 within 30 seconds. Then again there will be an attempt to reach my_home_ip_address.

upstream backend {
    server    my_home_ip_address    max_fails=3 fail_timeout=30s;
    server 127.0.0.1:8080  backup;
}

server {
    ...

    location /http/ {
        proxy_pass http://backend;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        ...
    }
}

A
Anton Spirin, 2018-05-21
@rockon404

I want to configure the system in such a way that in case of problems on the home server, all requests are sent to a copy of the site on the VPS server.

Here you need either a third server with nginx , or install nginx on a VPS and from there play football on your home computer, which is not rational.
If it's not a secret, why are you doing this?

I
Igor, 2018-05-21
@hostmaster

Amazon route53 is probably the easiest way, if suddenly your home server fails route53 will change dns records and send traffic to vps.
It's not free, but it's not expensive either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question