Bobcares

How to Set Reverse Proxy URL Rewrite in IIS?

by | May 18, 2024

Setting up a reverse proxy with URL rewrite in IIS can be useful for routing requests to different apps based on the URL. With our Server Support Services, we are here to help.

Overview
  1. Basic Terminologies
  2. Setting up a Reverse Proxy with URL Rewrite in IIS
  3. Benefits of Reverse Proxy with URL Rewriting in IIS
  4. Conclusion

Basic Terminologies

Enabling a reverse proxy with URL rewriting in Internet Information Services (IIS) provides various benefits to web-based apps, including increased performance, security, and user experience. Before we get into the details, let’s go over some of the basic terminology used in this article.

Internet Information Services (IIS): It is a flexible, secure, as well as easy-to-manage Web server that can host anything on the Internet. From media streaming to web apps, IIS’s scalable and open design is capable of handling the most demanding workloads.

Reverse Proxy: A reverse proxy is a server that stays between client devices and a backend server multiple servers, routing client requests to the correct backend server and returning the server’s response to the client. The reverse proxy appears to the client as the final server. Such a setup can also give several benefits, including load balancing, increased security, SSL termination, and caching.

URL Rewriting: URL rewriting is a method for updating URLs in order to make them more readable, understandable, and SEO-friendly. It includes turning a user-friendly URL into a format that a server can interpret and process. This can be done for a variety of reasons, including hiding query parameters, redirecting users, as well as simply improving the appearance of a URL.

In this article, we’re going to see 3 different methods we can use to deploy reverse proxy with URL rewriting in IIS.

Setting up a Reverse Proxy with URL Rewrite in IIS

Method 1

Here, we will enable reverse proxy functionality in IIS and create rewrite rules for the web apps.

Enabling Reverse Proxy Functionality

1. Initially, press Win + R, type inetmgr, and press Enter.

2. Then, select the server node in the left-hand tree view.

3. Now, click on “Application Request Routing”.

4. Also, check the “Enable Proxy” box. Leave the other settings as they are.

Creating Rewrite Rules for Web Apps. We need to create rules to route traffic to the webmail and payroll apps.

5. Go to %SystemDrive%\inetpub\wwwroot\.

6. Open the web.config file.

7. Add the following code under the /configuration/system.webServer section:

iis reverse proxy url rewrite
8. Save the web.config file.

Configuring Rules for Response Rewriting

9. Open IIS Manager and select “Default Web Site”.

10. Click on “URL Rewrite” in the Features View.

11. In the Actions pane, click “Add Rules…”.

12. Select “Blank Rule” under “Outbound Rules” and click “OK”.

13. Name the rule correctly (e.g., “Rewrite Links for webmail”).

14. Set the pattern to match the string in the response (e.g., ).

15. Define the action to replace it with the desired format (e.g., for webmail, and for payroll).

These steps will set up reverse proxy functionality in IIS and set up URL rewriting rules for the web apps.

Method 2

By default, IIS doesn’t support reverse proxy routing. In order to enable it, we must follow these simple steps:

1. Manually set up the necessary extensions for IIS to support reverse proxy routing.

2. Go to the URL Rewrite option in IIS Manager.

3. Click on “Actions” in the right toolbar, then select “Add Rule(s)…”.

4. Choose “Inbound rules” and create a new rule, either a “Blank rule” or a “Reverse Proxy rule”.

5. Click on the root level of the connection in the left toolbar.

6. Then, select “Application Request Routing Cache” option.

7. In the right toolbar, select “Server Proxy Settings…”.

8. Lastly, check the “Enable proxy” option.

Following these steps will enable reverse proxy routing in IIS, allowing us to efficiently manage incoming requests as well as route them to the correct backend servers.

Method 3

In order to set up forward proxy and URL rewriting in IIS, we must follow these steps:

1. Initially, start the IIS Manager and select the server.

2. Double click on the “Application Request Routing” option.

3. Click on “Server Proxy Settings” in the right-hand pane.

4. Check the “Enable proxy” checkbox.

5. Click “Apply” to save the changes.

6. In IIS Manager, select the website bound to the desired domain (e.g., http://yourdomain.com).

7. Double click on the “URL Rewrite” option in the admin console for the selected website.

8. Click on “Add Rule(s)…”.

9. Choose the “Blank Rule” template for an Inbound Rule.

10. Set the pattern to match the desired path (e.g., grafana(/)?(.*)).

11. Then, check the “Ignore case” checkbox.

12. Set the rewrite URL to http://localhost:3000/{R:2}.

13. Check both the “Append query string” and “Stop processing of subsequent rules” checkboxes.

14. Run the following command in Command Prompt:

iis reverse proxy url rewrite

15. Finally, go to http://yourdomain.com:8080/grafana to access the Grafana login page.

By following these steps, we’ll configure forward proxy and URL rewriting in IIS, allowing us to efficiently manage and route incoming requests for the Grafana app.

Benefits of Reverse Proxy with URL Rewriting in IIS

Setting up a reverse proxy with URL rewriting in IIS can offer many uses for web apps. These include performance, security, flexibility, and user experience improvements. Here’s a detailed look at the key benefits:

1. Load Balancing: Distributes incoming traffic across multiple backend servers to prevent any single server from becoming overloaded.

2. Enhanced Security: Hides the details of the backend infrastructure from clients and can block malicious requests. Also, by acting as an intermediary, the reverse proxy prevents direct access to the backend servers, reducing the attack surface.

3. SSL Termination: Offloads the SSL/TLS encryption and decryption process from backend servers. This also reduces the processing load on backend servers, allowing them to focus on handling application logic rather than cryptographic tasks.

4. URL Rewriting and Redirection: Allows for flexible and user-friendly URL structures, redirections, and routing rules. URL rewriting can transform complex URLs into simpler, more readable formats, enhancing user experience and SEO.

5. Caching: Stores copies of frequently requested content to reduce load on backend servers and speed up responses.

6. Centralized Authentication: Manages user authentication and authorization at the reverse proxy level. Also, simplifies the security architecture by handling authentication in one place, which can then pass authenticated requests to backend servers.

7. Simplified Maintenance and Upgrades: Allows backend servers to be updated, maintained, or replaced with minimal disruption to users. The reverse proxy can route traffic away from servers that are undergoing maintenance or upgrades, ensuring continuous availability.

8. Improved User Experience: Provides consistent, user-friendly URLs and enhances response times through various optimizations. Cleaner URLs are easier for users to read and remember.

9. Application Firewall: Filters and inspects incoming traffic before it reaches backend servers. Acts as an extra layer of defense against web-based attacks.

10. Flexibility and Scalability: Provides a flexible architecture that can easily scale as demand increases. It allows us to add or remove backend servers without affecting the front-facing URL structure or user experience.

[Searching solution for a different question? Click here to reach us.]

Conclusion

Implementing a reverse proxy with URL rewriting in IIS offers significant advantages in terms of performance, security, user experience, and scalability. By centralizing and optimizing traffic management, a reverse proxy ensures that the web application remains responsive, secure, and easy to maintain. This setup is particularly valuable for complex environments where multiple backend services need to be integrated and managed efficiently.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.