URL Rewrite Rule: HTTP to HTTPS Not Working in IIS 8 2016 Server: ERR_INVALID_REDIRECT - iis-8

I installed a godaddy SSL certificate. All these urls work in the browser:
"park.mydomain.com", "http://park.mydomain.com", "https://park.mydomain.com". The first two show unsecured and the last secured. In the bindings I have two entries. One [https park.mydomain.com port 443] and the other is [http park.mydomain.com port 80]. I installed URL rewrite and added a rule from this link: here. Now, if I type the first or the second url the browser says not found ERR_INVALID_REDIRECT. Only the third one that is https:park.mydomain.com works. If I disable the rule all three work again. What is wrong ? Why is it not redirecting ? The 2016 server with IIS is hosted in azure
<rewrite>
<rules>
<rule name="http_https" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_POST}/{R:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
</rewrite>

The redirection was setup correctly. The problem was on the type of certificate that I had installed, that was for one domain only.

Related

Duplicate, submitted URL not selected as canonical

I have my canonical tag URL as http://www.example.com/ in HTML header and also same in sitemap.xml. my host has enabled SSL and previously in search console I have been added HTTPS version of my address and three green check marks showed and was okay, then because SSL certificate was low quality some mobile phones couldn't reach it and I disabled SSL, but now Google selects HTTPS version of my address.
here is web.config
<rules>
<rule name="Redirect http://example.com to http://www.example.com HTTP" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*"></match>
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$"></add>
<add input="{HTTPS}" pattern="off"></add>
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" appendQueryString="true"></action>
</rule>
</rules>
its HTTPS version address goes to site control panel and certainly isn't same as HTTP version so that it chooses that one. any suggestions?

IIS hosted web application works fine with ssl without www, gives 404 error with www

Good morning.
I have a web application (made with angular if useful) hosted with IIS on a windows server 2016 with certificate (made with Let's Encrypts wacs) that works fine with ssl.
the problem is, if i use www the site not only appear as not safe, but also gives 404 error.
I tried the following rule on web.config to redirect to non www but without success
<rule name="Redirect WWW to non-WWW" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" />
</conditions>
<action type="Redirect" url="https://example.com/{R:1}" />
</rule>
I have other rules, thats my complete webconfig file: https://pastebin.com/wRWarfCV
I think https://www.example.com and https://example.com are Different domains. you need to reissue certificate and add http://example.com as primary domain and add other domain http://www.example.com.
More information you can refer to this link: How do I reissue my SSL certificate?.

URL should hit https instead of http

I am running a Windows Server, where i have hosted a site.
Now i have done the Binding with the SSL certificate for the site. But every time i hit the website URL, it goes to http instead of https. Althoough i have binded http & https with the SSL certificate.
Example -
when i try to hit abc.com
it goes http://example.com
instead of
https://example.com
Do i have to do anything more which can help me to fix this issue.
so everytime i try to visit
example.com
i will visit
https://example.com
Do anyone knows a way to fix this issue !
You need to add a redirect to make sure all traffic gets redirected, something like below. Make sure you have the URL rewrite module installed.
<rule name="HTTPS force" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>

Trying to access UpSource over https via IIS Reverse Proxy returns an empty page

I am currently trying to set up various Jetbrains services for use via https by using an IIS reverse proxy. The complete intended setup should looks somewhat like this:
TeamCity: https://server.company.com -> http://server.company.com
YouTrack: https://server.company.com/youtrack/ -> http://server.company.com:1234/issues/
Hub: https://server.company.com/hub/ -> http://server.company.com:5678/hub/
UpSource: https://server.company.com/upsource/ -> http://server.company.com:9876
I have already gotten this to work, with some difficulty, for TeamCity and YouTrack by using the following configuration:
In IIS, I have a TeamCity website that serves as a redirect. The web.config of that site currently looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Reverse Proxy to TeamCity" stopProcessing="true">
<match url="^teamcity/(.*)" />
<action type="Rewrite" url="http://server.company.com/{R:1}" />
</rule>
<rule name="Reverse Proxy to YouTrack" stopProcessing="true">
<match url="^youtrack/(.*)" />
<action type="Rewrite" url="http://server.company.com:8080/issues/{R:1}" />
</rule>
<rule name="Reverse Proxy to Hub" stopProcessing="true">
<match url="^hub/(.*)" />
<action type="Rewrite" url="http://server.company.com:8082/hub/{R:1}" />
</rule>
<rule name="Reverse Proxy to UpSource" stopProcessing="true">
<match url="^upsource/(.*)" />
<action type="Rewrite" url="http://server.company.com:8081/{R:1}" />
</rule>
<rule name="Reverse Proxy to Collaboration General" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://server.company.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
In addition, I have configured the following server variables as described in the documentation:
HTTP_X_FORWARDED_HOST
HTTP_X_FORWARDED_SCHEME
HTTP_X_FORWARDED_PROTO
However, when trying to access UpSource via https://server.company.com/upsource/, all I get is an empty page titled "Upsource". No error message. Not even a Fav Icon. Accessing UpSource via http://server.company.com:8081/ still works as normal though.
I have also already tried running the following chain of commands:
upsource.bat stop
upsource.bat configure --listen-port 8081 --base-url https://server.company.com:443/upsource/
upsource.bat start --J-Dbundle.websocket.compression.enabled=false
However, that did just caused the problem to change to:
HTTP ERROR: 404
Problem accessing /bundle/starting. Reason:
Not Found
Powered by Jetty:// 9.3.20.v20170531
How can I set up UpSource to work like TeamCity and Hub are already doing?
Any help on this would be greatly appreciated.
With some help of a YouTrack support employee helping with a related YouTrack error, I was able to figure out the reason behind this issue.
The reason is this: When accessing UpSource via https using a path for the redirect, the path needs to be the same in both the http and https variants.
In short, this will not work:
https://server.company.com/upsource -> http://server.company.com:9876
But this will:
https://server.company.com/upsource -> http://server.company.com:9876/upsource
I got this to work by running the following configurational command on the upsource.bat in [InstDir]/bin:
upsource.bat configure --listen-port 9876 --base-url http://server.company.com:9876/upsource
Now I can at the very least connect to and log in to UpSource via https. There's still a problem, but since it's unrelated to the topic of this question, I will create a separate question for it.
Note: on IIS 8.5 set HTTP1.1 at ARR PROXY-Settings. Otherwise the websocket connects, but there's no communication.
upsource v. upsource-2018.2.1291
https://www.jetbrains.com/help/upsource/proxy-configuration.html#IISreverseProxy

Azure Cloud Service redirect http to https not working (tried answers on many links)

I'm trying to do the 'simple' task of redirecting/rewriting traffic from http to https, I have one endpoint in a CloudService which is correctly configured for SSL.
I've tried many IIS rewrite rules, like the one below, but none are working. I've also tried setting up the rules via remote desktop on the IIS 8 server directly which also doesn't work.
When I enter any tag in the Azure web.config file the rewrite tag has a blue line under it with a message saying it is invalid under <system.webServer> :
<system.webServer>
...
<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="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
Any advice is much appreciated.
In order for these rules to work you have to configure both the endpoints - HTTP and HTTPS !!
If you have not configured plain HTTP endpoint on port 80, your server will never be hit by an Internet traffic, so rewrite rules will never trigger.Thus you get the timeout when you try opening the domain over plain HTTP. There is simply no process listening on port 80 when you haven't defined endpoint for it.