URL Rewrite Module - Redirect http to https to particular port - ssl

I am using URL Rewrite to redirect HTTP to HTTPS.
All the steps are done & working including the changes in web.config.
https://www.sslshopper.com/iis7-redirect-http-to-https.html
<rewrite>
<rules>
<rule name="RedirectToHTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
I am facing the below issue while redirecting.
I want to redirect the application to a port 90.
I have 2 applications, one is on default port & another is on 90 port.
So when somebody access -
http://xxx.xxx.x.xxx:90 then it is redirecting to :-
https://xxx.xxx.x.xxx
i want it to redirect to https://xxx.xxx.x.xxx:90
Any thought on how to do this?

It is not safe to use any other port with https. the default port for the https is 443.so it is recommended to use the default https port.
if you still want to use the different port with your HTTP binding then make sure your site binding is correct.
use the below rule to redirect the HTTP to https;
<rule name="redirect https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://192.168.3.66:90/{R:1}" />
</rule>
set the redirect URL based on requirement with https and port 90.

Related

IIS 8.5: Force all sites to use HTTPS

Wanting to know if there is a way to force all sites in IIS 8.5 to HTTPS instead of HTTP without having to create rewrite rules for each site we deploy to the box. We had one site get deployed to an internal server where the rules were not written in the config file and were just looking for a way to alleviate that miss in the future.
You can set this rule in applicationHost.config.
<rewrite>
<globalRules>
<rule name="http to https" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^Off$" />
</conditions>
<action type="Rewrite" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</globalRules>
</rewrite>

Application deploy in IIS

web Application deployed in IIS.Add port 443 for HTTPS.
And also create new SSL certificate for HTTPS.
finally,login in my application(its done).Once I refresh the browser.IIS 443 (Https)port automatically removed in IIS and application can't reached
It seems you don't set the url rewrite to redirect from http to https.
I suggest you could install the url rewrite module and add below url rewrite in the web.config to redirect all the request from http to https:
<rewrite>
<rules>
<rule name="Redirect to http" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" negate="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
</rule>
</rules>
</rewrite>
Details, you could refer to below article:
https://blogs.technet.microsoft.com/dawiese/2016/06/07/redirect-from-http-to-https-using-the-iis-url-rewrite-module/

IIS 8 Redirect to HTTPS Based on URL Address

Assume my server ip address was : http://192.168.1.100 (NON SSL)
And my domain name was : https://helloserver.com (SSL)
If someone was to access my website via the domain helloserver.com the server should automcatically redirect it to HTTPS.
I've managed to get that done by applying the below rule
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent"
url="https://{HTTP_HOST}/{R:1}" />
</rule>
But however if someone access the website from the IP Address itself, it'll give a certificate error because the ip address doesn't have a certificate.
How can i modify the below rule in away that when the IP Address is used to access the website it would use HTTP instead of the redirected HTTPS rule
I'm guessing it has something to do with <match url="" /> condition.
Any idea's?
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="^helloserver.com$" />
</conditions>
<action type="Redirect" redirectType="Permanent"
url="https://{HTTP_HOST}/{R:1}" />
</rule>

IIS URL rewrite rule from http to https for sub-domain

I have tried multiple IIS rewrite rules to redirect my sub-domain to https.
Question: How do I make my subdomain http://test.example.com to redirect to https://test.example.com. To provide more information the subdomain is not a folder but isolated website. Below rule didn't work for me.
<rule name="HTTP to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="^off$" ignoreCase="false" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
FYI: It works fine at my production website because there I could write a condition for www..

Force to use HTTPS redirects page to http://http/ url

I have added this code into my Configuration -> system.webServer section of web.config file to force users to use https:
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
redirectType="Permanent" />
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security"
pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
</outboundRules>
</rewrite>
But when I go to my website, it redirects page to this url:
http://http/
Notes:
I am using Orchard CMS version 1.10.x
When I use Orchard's SSL plugin to force all pages to use SSL, this happens again.
SSL Redirection is enabled in Orchard's settings.
SSL/TLS Certificate is correctly set in my Plesk control panel.
Website is currently secured using "Let's Encrypt". This issue happens when I use Cloudflare services too.
This happens on every web browser I've tested.
I use the same rewrite rules to redirect my pages to https using Orchard on a Plesk panel with Let's Encrypt certificates. This rule redirects every http call to https.
You have to disable the Orchard Secure Sockets Layer plugin since you make your own rules in web.config.
If you want to use the Orchard plugin, remove your rewrite rules and work with the plugin instead.