I have a couple of server addreses, like cdn1.website.com, cdn2.website.com, cdn3.website.com. Each of them holds simillar files.
Request comes to my server and I want to redirect or rewrite it to a random cdn server. Is it possible ?
Visitor–> Website Page–> Website is under maintenance. On the other hand, a permanent Nginx redirect informs the web browser that it should permanently link the old page or domain to a new location or domain. To map this change, the redirects response code 301 is used for designating the permanent movement of a page.
The proxy_pass setting makes the Nginx reverse proxy setup work. The proxy_pass is configured in the location section of any virtual host configuration file. To set up an Nginx proxy_pass globally, edit the default file in Nginx's sites-available folder.
You could try using the split clients module:
http {
# Split clients (approximately) equally based on
# client ip address
split_clients $remote_addr $cdn_host {
33% cdn1;
33% cdn2;
- cdn3;
}
server {
server_name example.com;
# Use the variable defined by the split_clients block to determine
# the rewritten hostname for requests beginning with /images/
location /images/ {
rewrite ^ http://$cdn_host.example.com$request_uri? permanent;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With