URL rewrite http to https not working for WCF web application in IIS - iis

I have added URL rewrite for Http to Https for website. But website has many web applications and URL rewriting is not working for web applications. It is showing 404 error
followed this url for http tp https https://www.ssl.com/how-to/redirect-http-to-https-with-windows-iis-10/
added rule to default website. but rule not working for web applications. How to apply rule to web applications too?
https://www.xyz1.com has url. I can see rule on web.config
https://www.xyz1.com/subsite/Testweb.svc - not working. rule not found in web.config

Related

HTTPS Only Not Working For Subdomain with Azure App Service

I have configured an Azure web service to use a custom domain and successfully verified both the root domain and subdomain (www) in addition to binding a TLS cert to both.
Custom domain page:
When I navigate to http://example.com, the browser correctly redirects to https://example.com.
However, when I navigate to the subdomain http://www.example.com, the browser does not redirect to https. I can however navigate directly to my subdomain over https via https://www.example.com.
Why is Azure not enforcing the "Https Only" setting on the subdomain?
Update: screenshot from TLS/SSL settings page:
It seems everything you have done is okay...
I just post what works on my side, you can have a look and check with yours.
After map custom domain, navigate to TLS/SSL settings, enable Https Only:
And ensure enable Https Only in custom domain page, too:
Here is my test:

Azure CDN custom domain for http redirects to .azurewebsites.net

I deployed my Umbraco 8 website to an Azure app service, created a CDN for the app service and configured the custom domain for the CDN.
In my domain provider (OVH) I added a CNAME for my domain so the Azure CDN could pass the verification.
My problem is that if go to a browser and type "https://www.culturaenvivo.com" everything works as expected. But if I type "www.culturaenvivo.com" the URL changes to the app service (cev.azurewebsites.net).
My CDN Origin configuration has both protocols configured.
What am I missing? Why is the URL changing to azurewebsites.net?
UPDATE: I added a rule engine in my Azure CDN to redirect from http to https but it doesn't seem to work either.
I tried and found that the HTTP redirect to HTTPS worked. When I input the http://www.culturaenvivo.com in the browser address bar, it always
redirect to https://www.culturaenvivo.com.
If this is what you expect in your browser, you could try to new inPrivate windows to open your websites or clear the browser cache or clear DNS cache or restart your machine to see if it helps.
To configure Azure CDN HTTP-HTTPS redirection, you could read this blog. For example, if you are using the Standard Microsoft CDN price tier, you can simply add a new rule as follows on the Azure portal.
It redirects from http to https now.
I added a .htacces file to my root folder with the following content
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.culturaenvivo.com/$1 [R,L]

Redirecting from web app behind Azure application gateway

I have two web apps setup in Azure, and for simplicity let's call them webapp1 and webapp2. They sit behind an application gateway, which is selecting the correct web app based on the subdirectory in the URL.
Here's a basic example of how I've set it up:
www.mydomain.com -> webapp1 (the default route)
www.mydomain.com/app -> webapp2
This is working fine, except for one problem: if webapp2 redirects to the login page, for example, the domain in the URL changes to the azurewebsites.net domain. Instead of redirecting to www.mydomain.com/login, it's going to webapp2.azurewebsites.net/login.
I'm fairly new to Azure application gateway, but I know it injects the x-forwarded-* and x-original-host headers. I assumed the gateway would either alter the redirected url request to correct the domain or the config on the web app would use the x-original-host instead. Neither of these things are happening.
Is there a way to configure either the web app or the gateway to make sure the host name doesn't change on redirects? Would this scenario work better with a separate web app/VM with a classic IIS reverse proxy setup instead of the application gateway?
Currently Application Gateway would not overwrite the response from the backend. We do inject X-Original-Host and your application should use that to write the redirect URL correctly back to mydomain.
Example to configure URL rewrite on web app can be found here. An example of rewriting default *.azurewebsites.net domain to a custom domain can be found here

How to rewrite URL based on http status code (IIS)

I am configuring a IIS reversed proxy that rewrite the URL and redirect request to an IIS server (ServerA) that serves a web service. In the case of failure, for example, a 503 http status code returned by the web service. I would like to rewrite the URL and redirect the request to another IIS server(ServerB) that serves a mirrored copy of the web service. Is this achievable? Thanks!

Can I route HTTPS requests to HTTP application, using IIS7 ARR?

I have an application server installed, listening for HTTP traffic on a port which is not blocked from the world by a firewall. I wish to expose the services offered by this application only through HTTPS, preferably as a "sub directory" of the HTTPS site already hosted by the server.
Using IIS7 Url Rewriting (as part of the ARR package), I am able to setup a rule that redirects all traffic to a sub path of my existing HTTPS site. However, I am facing some trouble, when trying to make the same rule route to my server farm setup - all requests matching the rule simply get 404 reponses. Adding the very same rule to a non-SSL site, yields the expected behaviour - the application services are proxied right trough.
What might be wrong in my setup? Is ARR proxying the HTTPS requests as HTTPS traffic to the application server? The application I want to host does not have a HTTPS interfaces so, if yes: can I tell it not to do so?
Yes, I can use IIS7/ARR to route HTTPS requests to HTTP application.
The problem I experienced, was caused by the fact that the web site I wanted to use as the "container" for the proxy directory was buildt with ASP.NET MVC. The URL routing framework within ASP.NET interfered with the IIS url rewriting, and causes the 404 error.

Resources