How do I map a port to a different port with IIS rewrite rules?

Tim 21 Reputation points
2023-02-10T06:46:34.7933333+00:00

I want to proxy public ports, for example 20001, to a local port that's always 5000 lower (15001). How can I accomplish this using rewrite rules?

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,520 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tasadduq Burney 8,671 Reputation points MVP
    2023-02-10T08:43:01.8066667+00:00

    Here are the steps to accomplish your goal :

    1. Open IIS Manager and navigate to the website you want to configure.
    2. In the Features View, double-click URL Rewrite.
    3. In the URL Rewrite module, click the Add Rule(s) action in the right-side panel.
    4. Select Reverse Proxy as the rule template, then click OK.
    5. In the Inbound rule section, specify the following information:
      • Rule name: Give the rule name like "Reverse Proxy Port 20001 to 15001".
      • Requested URL: Matches the Pattern.
      • Using: Wildcards.
      • Pattern: :20001/
    6. In the Outbound rule section, specify the following information:
      • Server Proxy Pass Through: Checked.
      • URL Rewrite: Unchecked.
      • Reverse rewrite host in response headers: Checked.
      • To: The URL of the local website or application, using the local port, for example: http://localhost:15001
    7. Click Apply in the right-side panel to save the changes.

    With this configuration, incoming requests to http://[domain]:20001/ will be redirected to http://localhost:15001/.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.