Ahmad Behzadi
Ahmad Behzadi

Reputation: 1026

IIS 10 rewrite to internal port for both http and https

I have a node js application running on the port 8080 in my Windows server and is accessible from inside of the server by http://localhost:8080. I want to use some subdomains like app.mydomain.com without using the port number from outside of the server to open this node.js application. I want to completely all traffics be rewrited to this port and there is no filters for subdirectories.

I've installed ARRv3_0 and urlrewrite2 on my IIS and also restarted the server too. Also installed a certificate on the server and assigned to this IIS website. Currently, I'm using this file as my web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Reverse Proxy to node server" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                </rule>              
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Also, I created an index.html file in the website directory too, but there is no difference.

enter image description here

I get 404 when I open the domain with both http and https.

enter image description here

Upvotes: 0

Views: 1775

Answers (1)

Bruce Zhang
Bruce Zhang

Reputation: 3042

There are some tips you need to pay attention to.

  1. You need to check the Enable proxy in ARR. ARR->Server Proxy Settings-> Enable proxy. enter image description here
  2. According to your proxy rules, when you proxy from one URL to another, only the domain is rewritten, so you have to make sure that there is page information in the URL, such as http://initialURL/index.html, and it will be the last Rewrite to http://localhost:8080/index.html. If you don't want to add index.html, you can enable default document and move index.html to first one. enter image description here

Upvotes: 1

Related Questions