1

I have set up the subdomain reg.example.com on a dedicated windows server 2019 (not the same server as example.com). The main url works when I don't type https (I simply enter reg.example.com in address bar and it is being redirected to https due to web.config settings). But when I call a subfolder without https e.g reg.example.com/exam the server is not responding. If I force https manually and type https://reg.example.com/exam with https it works!

Conditions:

  • the reg.example.com is the default website on IIS.

  • website bindings is set on port 80 for http and port 443 for https and assigned the propper SSL to https.

  • I have tried checking and unchecking "Require server name indication" when assigning the ssl but no change.

  • There is A record for reg.example.com on DNS server pointing to the server IP.

  • Browsers redirect from http to https but the curl command for main doman (even without subfolders) curl --head http://reg.example.com/ says: curl: (7) Failed to connect to reg.example.com port 80: Connection refused

  • these are the codes used in web.config to redirect requests to https: and remove default document from urls:

    <rule name="RemoveWWW" patternSyntax="Wildcard" stopProcessing="true">
        <match url="*" />
        <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="www.reg.example.com" />
        </conditions>
         <action type="Redirect" url="https://reg.example.com/{R:0}" redirectType="Permanent" />
    </rule>
    
    
     <rule name="RemoveDefaultDocument" stopProcessing="true">
         <match url="(.*?)/?index\.asp$" />
         <conditions>
             <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
         </conditions>
         <action type="Redirect" url="{R:1}/" redirectType="Permanent" />
     </rule>
    
     <rule name="HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
         <match url="*" negate="false" />
         <conditions logicalGrouping="MatchAll">
             <add input="{HTTPS}" pattern="off" />
             <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
         </conditions>
         <action type="Redirect" url="https://reg.example.com/{R:0}" redirectType="Permanent" />
     </rule>
    

and finally this is the error I receive after 2-3 minutes:

This site can’t be reached reg.example.com refused to connect.

4
  • Have you tried any redirect testing tools like using curl --head http://reg.example.com/ on the command line? you can download it and view its documentation here: curl.se Sep 23 at 16:40
  • Browsers redirect from http to https but the curl says: curl: (7) Failed to connect to reg.example.com port 80: Connection refused (example.com was replaced with main domain) @StephenOstermiller Sep 23 at 17:30
  • That means your browser has the redirect cached and that your server is no longer working. If you clear your browser cache it is going to start having connection refused for the base URL on HTTP as well. I don't know much about IIS, but your HTTP binding on port 80 must be broken somehow. Sep 23 at 17:36
  • 2
    "That means your browser has the redirect cached and that your server is no longer working." Or you use the newer browsers versions and the associated settings that make them try HTTPS first in all cases, without bothering with HTTP at all. See theverge.com/2021/7/14/22577151/… or blog.mozilla.org/security/2020/11/17/… Sep 23 at 17:57
3

In this case the problem was that port 80 was redirected to 443 in windows firewall settings. I removed the port forwarding and port 80 is now working on all URLs.

Perhaps the main url http://reg.example.com was working from cache, not sure....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.