HOW TO SECURE A WINDOWS SERVER WITH IIS AND AZURE NETWORK SECURITY FEATURES
Tags: iis, webserver, cloudcomputing, azure
Published: 2024-05-30 17:30:35

In today's digital landscape, ensuring the security of your network's infrastructure is paramount. With the increasing prevalence of cyber threats, it's crucial to implement robust security measures to protect your assets and data. In this blog post, we'll walk through the steps of setting up a Windows Server with Internet Information Services (IIS) installed, and then we'll enhance its security using Azure's network security features.

**Step 1: Installing IIS on the Windows Server**
The first step in setting up our environment is to install Internet Information Services (IIS) on our Windows Server. IIS is a flexible and scalable web server that provides a secure and reliable platform for hosting websites and web applications.

To install IIS on the server, follow these steps:

- Log in to your Windows Server.
- Open Server Manager.
- Click on "Manage" and then select "Add Roles and Features."


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bha55pk1uucvm148nl79.png)


-  In the Add Roles and Features Wizard, click "Next" until you reach the Server Roles section.
- Check the box next to "Web Server (IIS)" and click "Next" to install the required features.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92nxl9b7t5rd759an6zb.png)


- Follow the on-screen instructions to complete the installation.

**Step 2: Creating an Application Security Group**
Next, we'll create an Application Security Group (ASG) in the same region as our server. ASGs allow us to define network security policies based on the application workloads rather than individual IP addresses.

To create an ASG, follow these steps:

- Log in to the Azure portal.
- Navigate to the Networking section and select "Application security groups."
- Click on "Add" and provide the necessary details, such as name and region, for the ASG. In the example below, we want to create an ASG named AndrosServer-ASG.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9xp3jpcp161yy6yjqv1.png)


- Once the ASG is created, you can associate it with the appropriate resources, such as virtual machines or subnets, to define security rules.

**Step 3: Adding Inbound Rules to the Server's Network Security Group**
Now, let's add inbound rules to the Network Security Group (NSG) associated with our server. NSGs act as a basic firewall to control traffic to and from network interfaces in Azure.

To add inbound rules to the NSG, follow these steps:

- Navigate to the Networking section in the Azure portal and select "Network security groups."
- Find the NSG associated with your server and click on it. In the example below, the associated NSG is ServerA-nsg.
- In the NSG's settings, select "Inbound security rules" and click on "Add."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8dr4mn23e0jx2a72kuh6.png)


- Create a rule to allow traffic on port 80 (HTTP) and port 443 (HTTPS) from the desired source IP ranges or Application Security Groups.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sqxu6cbfky40zys5qjzt.png)


- Save the changes to apply the new inbound rules.

**Step 4: Creating and Attaching a Firewall to the Server's VNet**
To further enhance the security of our environment, we'll create a firewall and attach it to the server's Virtual Network (VNet). This firewall will provide additional layers of protection against malicious threats.

To create and attach a firewall to the VNet, follow these steps:

- Navigate to the Networking section in the Azure portal and select "Firewalls."
- Click on "Add" to create a new firewall resource.
- Configure the firewall settings, such as name, region, and firewall type.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cr1ptv9ydxzua9f2zpcl.png)


- Once the firewall is created, navigate to the Virtual Network section and select the VNet associated with your server.
- In the VNet's settings, select "Firewall" and click on "Attach."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/namj1g7v15911t1l685w.png)


- Choose the newly created firewall from the list and complete the attachment process.

**Step 5: Testing Connectivity**
Finally, let's test the connectivity to our server by copying its public IP address into a web browser. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ro05wqakxzdtg5vpncp.png)


If the setup is successful and the security configurations are applied correctly, you should be able to access the server's IIS landing page without any issues.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jgmsxj30dgdgxh7h3cnb.png)



**Conclusion**
By following these steps and leveraging Azure's network security features, you can effectively secure your Windows Server with IIS installed. From configuring inbound rules to creating firewalls, each step plays a crucial role in safeguarding your environment from potential threats. With a proactive approach to security, you can mitigate risks and ensure the integrity of your network infrastructure.