Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a site where any traffic coming in on port 80 needs to be redirected to port 443 (https). According to this article, that is easy enough and it works. My problem is, however, that this is a load balanced environment. I want to open up a non standard port behind my firewall so that when my sever is off the load balancer I can push my code and test it using http://myip:XXXX via http on the non-standard port without it forcing https.

The rule used in the article is this

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>

How can I tweak this so it only redirects for port 80 (or doesn't redirect for my test port)?

share|improve this question

1 Answer 1

The web.config file is site-centric (or rather, directory-centric, to the directory it's sitting in), regardless of which port you hit it on.

The trick (and I've never done this in regards to ports) is going to be to change your URL match rule to match URL requests that end in :80. My initial guess would be that changing it to (.*:80) might just work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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