Multi-ISP WAN Failover

Have a nice day, everyone!

I have the following network configuration:
NetworkRouting.jpg
There are several sites like site1 and site2!
I cannot manage WAN. It looks like a LAN with forbidden broadcasting to me.

I need to configure the routers so that if the main router is unavailable from the WAN, the site1 router automatically determines that it is necessary to send packets to the site2 router and site2 the router “understands” that to access the server, all packets must be sent through the VPN.
NetworkRoutingFailover.jpg
As far as I understand, I need to apply an OSPF.
Can you explain in detail (or give a link to an existing article) how to set it up?
Thanks a lot for any hints.

I configured OSPF, everything seems to be working. (if you are wondering, I had a problem setting up the firewall, so the OSPF didn’t work right away)
But I see that OSPF forms such “multiple” routes:
OSPF Routing.PNG
Is this bad and means that the packet can be sent through any interface? Need to adjust the cost of routes? Or is everything ok?

You are not an ASN. You need only one edge router and managed switches to get this running. VLAN segregate the network.

Why do you have two extra routers for? You have a public /24 or something from the ISP?

How are the sites connected if you can connect them without internet (same building and by what medium, fiber, ethernet, telephone line)?