Nginx – Expert Network Consultant https://www.expertnetworkconsultant.com Networking | Cloud | DevOps | IaC Tue, 11 Apr 2023 07:04:57 +0000 en-GB hourly 1 https://wordpress.org/?v=6.3.5 Create an Application Gateway with Path Routing to Backend Pools https://www.expertnetworkconsultant.com/expert-approach-in-successfully-networking-devices/create-an-application-gateway-with-path-routing-to-backend-pools/ Wed, 12 Apr 2023 00:01:20 +0000 http://www.expertnetworkconsultant.com/?p=6098 Continue readingCreate an Application Gateway with Path Routing to Backend Pools]]> In this article, we’ll walk you through the process of creating two Linux Ubuntu VMs and an application gateway with path routing to one VM as an image server and the other as a video server. This setup will enable you to serve static assets, such as images and videos, from separate VMs, which can help distribute traffic and improve performance

Note: I have used this SKU size as it’s lightweight and sufficient for this lab exercise – Standard B1s (1 vcpu, 1 GiB memory)

First, we’ll create two Linux Ubuntu virtual machines in Azure. We’ll use Azure because it offers a quick and easy way to create virtual machines.

Step 1:

  • Sign in to the Azure portal.
  • Click on “Create a resource” in the top left corner of the screen.
  • Search for “Ubuntu Server” and select the “Ubuntu Server 18.04 LTS” option.
  • Choose a subscription, resource group, virtual machine name, region, and size for the virtual machine. You’ll need to create one VM for the image server and another for the video server.
  • Set up a username and password for the VM.
  • Choose “SSH public key” as the authentication type.
  • Create an SSH key pair if you don’t already have one.
  • Click “Review + create” to review your settings and create the VM.

Repeat this process to create a second VM for the video server.

Step 2: Configure the Virtual Machines

create linux virtual machines

Next, we’ll configure the virtual machines to serve static assets. We’ll use Nginx as the web server, but you can use any web server you prefer.

SSH into the image server VM or use Azure Run Command Tool.
Install Nginx by running the command

"sudo apt-get update && sudo apt-get install nginx".

Copy your images to the VM and place them in the “/var/www/html” directory.
Repeat this process on the video server VM, but copy your videos to the “/var/www/html/videos” directory.

A step by step walkthrough as per below;
Install Nginx

sudo apt-get -y update
sudo apt-get -y install nginx

Create Images Folder Path

mkdir /var/www/html/images/
echo "<h1> This is the Images Server </h1>" > /var/www/html/images/index.html

Create Videos Folder Path

mkdir /var/www/html/videos/
echo "<h1>This is the Videos Server</h1>" > /var/www/html/videos/index.html

Step 3: Create the Application Gateway

Now, we’ll create the application gateway in Azure. This will enable us to route traffic to the correct VM based on the URL path.

  • Sign in to the Azure portal.
  • Click on “Create a resource” in the top left corner of the screen.
  • Search for “Application Gateway” and select the “Application Gateway v2” option.
  • Choose a subscription, resource group, name, region, and SKU for the application gateway.
  • Choose the “Backend pools” option in the left menu.
  • Click “Add” to add a backend pool.
  • Choose the “Virtual machines” option for the backend target type.
  • Choose the image server and video server virtual machines as the targets.
  • Choose the “HTTP settings” option in the left menu.
  • Click “Add” to add an HTTP setting.
  • Choose a name for the HTTP setting and configure the protocol, port, and cookie settings.
  • Choose the “Rules” option in the left menu.
  • Click “Add” to add a rule.
  • Choose a name for the rule and configure the listener, backend target, and URL path map settings.
  • Test your application gateway by accessing the image and video servers through the gateway URL with the appropriate path.

Create Application Gateway

create application gateway

create application gateway public ip
create application gateway public ip

create application gateway with images backend pool
create application gateway with images backend pool

create application gateway with videos backend pool
create application gateway with videos backend pool

create application gateway routing rules

create application gateway listener

create application gateway images backend setting
create application gateway images backend setting

create application gateway add multiple targets to create path-based rule
create application gateway add multiple targets to create path-based rule

create application gateway add multiple images path-based rule
create application gateway add multiple images path-based rule

create application gateway videos backend setting
create application gateway videos backend setting

create application gateway add multiple videos path-based rule
create application gateway add multiple videos path-based rule

create application gateway add backend targets
create application gateway add backend targets

create application gateway frontend routing rules for backend pools
create application gateway frontend-routing-rules-backend-pools

Browse to Video Server Resource
this is the videos server

create application gateway and check health
create application gateway and check health

Check Overview of Application Gateway
overview of application gateway http requests

Awesome links for further reading;
Apache web server documentation: https://httpd.apache.org/docs/
Azure documentation: https://docs.microsoft.com/en-us/azure/
Ubuntu server documentation: https://ubuntu.com/server/docs
Virtual machines in Azure: https://docs.microsoft.com/en-us/azure/virtual-machines/
Application Gateway in Azure: https://docs.microsoft.com/en-us/azure/application-gateway/

]]>