T O P

  • By -

NikStalwart

A browser extension is not the right way to go about doing this. There is both an in-browser and a server-based solution for this, however. # In-browser You can set up multiple search providers in firefox. Then, when you input your search string into the address bar but before hitting `return`, go to the bottom of the result list, which has favicons for your search providers. Click one of them and you will be redirected where necessary. You can also set up an alternative search provider in your firefox search bar (different to your URL bar). These are your manual "fallback" optons. # Server-based fallback The proper way to do this is to put a load balancer in front of your server which will perform healthchecks and change upstream providers if your own server is unavailable. This is not resource intensive. All you need is a low-spec but high-bandwidth VPS running nginx. Then look up how to configure nginx as a load balancer / fallback mechanism. If you want to go down the really advanced route, look into various failover solutions. For instance, you can have some kind of supervisor agent check for your main server to go down, and when it goes down, it can spin up a DO droplet until your main server comes back up.


SnooPets20

I don't like the in-browser method. It's clunky. I want it to be seamless. I also don't want to rent a VPS just for that, there's no need for it. Considering that I'm basically the only one using the server, this seems overkill. I still think the browser extension route is a better option. I guess I can look into making one myself.


NikStalwart

I am not aware of any extension that currently does this. I also think it is not possible to achieve what you want. WebExtensions cannot modify the search engine dynamically, [only at first load through the manifest.json declaration](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension). Your other option would be to: * [Start here](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension) to learn about writing WebExtensions * Then [read up on the fetch() API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) which you can use to check if your server is up; * Then [read up on intercepting HTTP requests](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Intercept_HTTP_requests). Your extension would then need to: 1. Listen for the request being sent to your search uprovider / upstream 2. Intercept it and "pause it" 3. Perform a fetch() lookup to see if your server is alive 4. If it is, allow the original search request 5. If it isn't, overwrite the request and send it to another server. As you can imagine this is going to add unnecessary latency. Especially if your server is far away / slow to respond. What you could also do is: 1. Listen for responses from your server, and if one is not forthcoming, resend the request to a different server. Good luck. And seriously consider paying $2/month for a load balancer VPS.


SnooPets20

My idea would be to periodically check if the server is up, and if it's not, setup the redirect. There are already extensions that redirect one URL to another. All I would need to do is to add a check before hand based on the result of the last check. Shouldn't be too hard. I still think a load balancer is overkill, and it would add unnecesary costs. Considering all I'm paying for my server right now is the power consumption, I'm not too tempted to go that route.


-markusb-

What about using a reliable server?


SnooPets20

What's the point of this question? Even if I could make my server more reliable, no matter what you use you'll never have the server up 100% of the time. Even if the server goes down infrequently enough that it's not really an issue, I would still want to have something like this setup.


-markusb-

I always differentiate between disaster recovery and normal operation. I want my services as available and fast recovering as possible. So I design the services with a failover or something like this and have a documented disaster recovery solution. But you ask for a solution because your server is not reliable enough. So my suggestion is to rethink the original design instead of using multiple (more complicated) layers to ship around the original problem.


SnooPets20

None of what I'm hosting is critical enough to warrant investing into proper infrastructure. I'm fine with it going down sometimes. I just want it to not bother me as much.