Skip to content

Commit

Permalink
Make origin endpoint use edge server as backup vice versa
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Dec 10, 2024
1 parent 0ca6075 commit 41beeb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nginx/install_and_configure_nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ update_nginx_config() {

# Generate the server blocks configuration based on the IP addresses
origin_server_blocks=""
origin_server_blocks_backup=""
for ip in "${origin_server_ips[@]}"; do
origin_server_blocks+="\n server $ip:$HTTP_PORT;\n"
origin_server_blocks_backup+="\n server $ip:$HTTP_PORT backup;\n"
done

rtmp_origin_server_blocks=""
Expand All @@ -81,14 +83,21 @@ update_nginx_config() {
done

edge_server_blocks=""
edge_server_blocks_backup=""
for ip in "${edge_server_ips[@]}"; do
edge_server_blocks+="\n server $ip:$HTTP_PORT;\n"
edge_server_blocks_backup+="\n server $ip:$HTTP_PORT backup;\n"
done


sudo sed -i "s/{{ORIGIN_SERVER_BLOCKS}}/$origin_server_blocks/g" $nginx_config
sudo sed -i "s/{{ORIGIN_SERVER_BLOCKS_BACKUP}}/$edge_server_blocks_backup/g" $nginx_config #put edge servers as backup for origin servers

sudo sed -i "s/{{RTMP_SERVER_BLOCKS}}/$rtmp_origin_server_blocks/g" $nginx_config
sudo sed -i "s/{{ORIGIN_SRT_SERVER_BLOCKS}}/$srt_origin_server_blocks/g" $nginx_config
sudo sed -i "s/{{EDGE_SERVER_BLOCKS}}/$edge_server_blocks/g" $nginx_config
sudo sed -i "s/{{EDGE_SERVER_BLOCKS_BACKUP}}/$origin_server_blocks_backup/g" $nginx_config #put origin servers as backup for edge servers

sudo sed -i "s/{{YOUR_DOMAIN}}/$domain/g" $nginx_config

# Check if a ssl enabled name is provided
Expand Down
2 changes: 2 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ http {
upstream antmedia_origin {
least_conn;
{{ORIGIN_SERVER_BLOCKS}}
{{ORIGIN_SERVER_BLOCKS_BACKUP}}
#server {AMS_ORIGIN1_IP}:5080;
}

Expand All @@ -62,6 +63,7 @@ http {
upstream antmedia_edge {
least_conn;
{{EDGE_SERVER_BLOCKS}}
{{EDGE_SERVER_BLOCKS_BACKUP}}
#server {AMS_EDGE1_IP}:5080;
}

Expand Down

0 comments on commit 41beeb3

Please sign in to comment.