I have two separate file servers with different files inside.
For example:
Server 1:
file1.mp4
file2.mp4
Server 2.
file3.mp4
file4.mp4
What would be the easiest way to access the files with the same domain?
For example:
https://example.com/file1.mp4
https://example.com/file2.mp4
https://example.com/file3.mp4
https://example.com/file4.mp4
If using nginx you could use this config on each of your servers, for example for server1
:
upstream failover{
server server2:8080;
}
server {
listen 80;
server_name example.com;
root /tmp/test;
location ~* \.(mp4)$ {
try_files $uri @failover;
}
location @failover {
proxy_pass http://failover;
}
}
In this example, for files ending in .mp4
if not found in the server they will use the @failover location, the one is going then to proxy the request to server
via an upstream.
For server2
you do the same but just change the address in the upstream, for example:
upstream failover {
server server1:8080
}
In any case, if the file .mp4
is not found in either of the servers you still getting a 404
HTTP status code.