http to https redirect with reverse proxy

Jon_AK 0 Reputation points
2023-05-22T23:36:43.9333333+00:00

Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for workstations attached to the LAN & not for incoming website calls from the internet. In the web.config file, the http to https rule occurs first which is what the recommendation from a Microsoft article stated. I have reviewed what seems like a thousand web links that have one or the other but not both. Anybody have information on how to make this work?

Windows development Internet Information Services
Windows for business Windows Server User experience Other
{count} votes

3 answers

Sort by: Most helpful
  1. Limitless Technology 44,751 Reputation points
    2023-05-23T11:12:26.6566667+00:00

    Hello Jon,

    Thank you for your question and for reaching out with your question today.

    Assuming http traffic comes via port 80, you may redirect to https by adding an extra server block listening to this port: server { listen 80; server_name exampleserver.com; location / { return 301 https://exampleserver.com$request_uri; } }

    If the reply was helpful, please don’t forget to upvote or accept as answer.

    Best regards.

    0 comments No comments

  2. Jon_AK 0 Reputation points
    2023-05-23T12:52:10.5666667+00:00

    Thanks for responding. Not sure if posting a response to a comment is visible to everyone so will post it here.

    I have a rule for http to https redirect followed by a rule for reverse proxy. I created these based upon examples posted on the internet. Traffic from the internet to our erp/website is not redirected to https and remains as non-secure but traffic from within the lan is redirected to secure. The rule is supposed to be set to match a pattern using regular expressions but there is no response when trying to log onto the website. I changed that to use wildcards & that allows traffic to logon. My current web.config is attached is you would be so kind to review it and make suggestions.webconfig.txt

    0 comments No comments

  3. Yurong Dai-MSFT 2,846 Reputation points Microsoft External Staff
    2023-05-24T09:46:31.66+00:00

    Hi @Jon_AK,

    Traffic from the internet to our erp/website is not redirected to https and remains as non-secure but traffic from within the lan is redirected to secure.

    For us, it is impossible to reproduce your problem, the best way is to use Failed Request Tracing, it will provide the key error and warning, which will help you to identify the problem. And you can see how the rules are used internally.

    This link provide the method to enable failed request tracing to capture the detailed error:

    https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules

    In addition, you need to check your firewall and port forwarding settings to make sure your network firewall or router is properly configured to forward incoming internet traffic on port 80 (HTTP) and port 443 (HTTPS) to the appropriate internal IP address of your web server.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,

    Yurong Dai


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.