My Azure web app (example.azurewebsites.net) has one custom domain, applicationhost.config:
<sites>
<site name="example" id="111111111">
<bindings>
<binding protocol="http" bindingInformation="*:80:customdomain.com" />
<binding protocol="https" bindingInformation="*:443:customdomain.com" />
<binding protocol="http" bindingInformation="*:80:example.azurewebsites.net" />
<binding protocol="https" bindingInformation="*:443:example.azurewebsites.net" />
</bindings>
<application path="/" applicationPool="example" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="D:\home\site\wwwroot" />
<virtualDirectory path="/iisnodedebugger" physicalPath="C:\DWASFiles\Sites\example\Temp\iisnode" />
</application>
<traceFailedRequestsLogging enabled="false" customActionsEnabled="true" directory="D:\home\LogFiles" />
<detailedErrorLogging enabled="true" directory="D:\home\LogFiles\DetailedErrors" />
<logFile logSiteId="false" />
</site>
...
</sites>
The custom domain's bindigs are automatically added to the default site (example).
I would like to change it, i would like to create a new site with bindings to the custom domain (customdomain.com).
applicationHost.xdt (created with IIS Manager):
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.applicationHost>
<sites>
<site name="example" xdt:Locator="Match(name)">
<bindings>
<binding bindingInformation="*:443:customdomain.com" xdt:Locator="Match(bindingInformation)" xdt:Transform="Remove" />
<binding bindingInformation="*:80:customdomain.com" xdt:Locator="Match(bindingInformation)" xdt:Transform="Remove" />
</bindings>
</site>
<site name="customdomain" id="222222222" xdt:Transform="InsertAfter(/configuration/system.applicationHost/sites/site[(#name='example')])">
<bindings>
<binding protocol="http" bindingInformation="*:80:customdomain.com" />
<binding protocol="https" bindingInformation="*:443:customdomain.com" />
</bindings>
<application path="/" applicationPool="example" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="D:\home\site\wwwroot2" />
<virtualDirectory path="/iisnodedebugger" physicalPath="C:\DWASFiles\Sites\example\Temp\iisnode" />
</application>
</site>
</sites>
</system.applicationHost>
</configuration>
After restart the transform is successfull.
The problem: it has no effect. The customdomain.com is still served from "D:\home\site\wwwroot" and not "D:\home\site\wwwroot2".
After that i deleted only the bindigs without adding the new site, customdomain still working... After that i deleted the whole site (example), example.azurewebsites.net and customdomain.com still working.
Where am I mistaken? Isn't it possible to manipulate the sites section?
May i ask why are you trying to make your life hard?
Why don't you deploy your 2nd application to a new Web App? You can share the same App Service Plan (same VM) if cost is the essence here.
Every Web App has its own custom domain settings which you can configure visually through the Portal:
https://azure.microsoft.com/en-gb/documentation/articles/web-sites-custom-domain-name/
i did this in the webconfig and it seems to work:
**<rule name="REDIRECT To Site Within a Site" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}"pattern="^www\.SiteWithinSiteName\.com$" />
<add input="{PATH_INFO}" pattern="^/path/SiteWithinSiteRoot/" negate="true" />
</conditions>
<action type="Rewrite" url="\path\SiteWithinSiteRoot\{R:0}" />
</rule>**
Related
I'm trying to redirect from the root IIS Url to root/myapp, using the following URL Rewrite rule in IIS:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect Root" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{PATH_INFO}" pattern="^/$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/test" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This works when I use https://localhost/, however when I use https://my-public-domain/ it doesn't redirect to https://my-public-domain/myapp as needed.
The Default Web Site has a HTTPS binding with an SSL certificate.
<site name="Default Web Site" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<application path="/MyApp" applicationPool="MyAppAppPool">
<virtualDirectory path="/" physicalPath="C:\Program Files\IIS\MyApp" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
<binding protocol="https" bindingInformation="*:443:" sslFlags="0" />
</bindings>
<traceFailedRequestsLogging enabled="true" />
</site>
How can I achieve this?
I have an old WCF webservice that's been moved to Azure VM.
I can easily access in Azure:
https://wcf/service.svc,
but when I try to post to:
https://wcf/service.svc/json/DoAction
it comes back with an empty response, when I open this in the browser I get 404 error.
Outside of Azure it all works fine, any ideas what can I do to get it to work? I would like to keep it running in VM as there are other items that were moved and work fine.
Here is the part of the web.config file that relates to "/json/" part:
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service name="Service123" behaviorConfiguration="ChallengeBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="ChallengeMessageEncoding" contract="IService123" behaviorConfiguration="SoapServiceBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestServiceMessageEncoding" contract="IService123" behaviorConfiguration="RestServiceBehavior" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RestServiceBehavior">
<webHttp defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
</behavior>
<behavior name="SoapServiceBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="RestServiceMessageEncoding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="ChallengeMessageEncoding">
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" />
<message clientCredentialType="None" establishSecurityContext="false" negotiateServiceCredential="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
There is no problem the code snippets seem to me. Which version IIS is installed in the Azure VM? Do you have enabled the feature supported for WCF in IIS.
I suspect that the WCF service published on the VM does not work properly. Try to publish a default WCF service application project and browse the self-introduction page.
In addition, for a specific port, you need to enable outbound/inbound permission on the firewall.
VM>>Settings>>Network
Feel free to contact me if there is anything I can help with.
#Abraham, thank you for your answer.
I finally got it working, not sure which part helped but changes I introduced included:
a) Installed additional WCF features (as above) as only 2 were installed
b) Added extra bits to web config (allowing to run URLs with dots in name /Foo.svc/Save )
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<clear />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="/*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
c) Another config to support dots:
<modules runAllManagedModulesForAllRequests="true" />
d) Extended endpoints to support HTTPS as the above started working for HTTP:
<service name="PrivateService" behaviorConfiguration="PrivateBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehavior" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PrivateBehaviorSecure" contract="IPrivateService" behaviorConfiguration="SoapBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="RestSecure" contract="IPrivateServices" behaviorConfiguration="RestBehavior" />
<endpoint address="/json" binding="webHttpBinding" bindingConfiguration="Rest" contract="IPrivateService" behaviorConfiguration="RestBehavior" />
</service>
...
<webHttpBinding>
<binding name="Rest">
<security mode="None">
</security>
</binding>
<binding name="RestSecure">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" />
</security>
</binding>
</webHttpBinding>
I tried to reinstall iis on my windows 10 system through Control Panel\Programs and Features\ Turn Windows features on or off but after uninstalling it there is a problem with installing iis again.
Here are screenshots with all errors I'm facing at the moment:
In folder Windows/System32/inetsrv/config I recreated file named ApplicationHost.config
here is the configuration:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<system.applicationHost>
<applicationPools>
<add name="DefaultAppPool" />
<applicationPoolDefaults>
<processModel identityType="NetworkService" />
</applicationPoolDefaults>
</applicationPools>
<customMetadata />
<listenerAdapters>
<add name="http" />
</listenerAdapters>
<log>
<centralBinaryLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<centralW3CLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
</log>
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%SystemDrive%\inetpub\logs\LogFiles" />
<traceFailedRequestsLogging directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles" />
</siteDefaults>
<applicationDefaults applicationPool="DefaultAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
<webLimits />
</system.applicationHost>
</configuration>
Does anyone had something like that before me and was able to run IIS again without reinstalling entire system from scratch?
If any information needed please do not hasitate to ask in comment section.
Thanks in advance :)
Thanks to #LexLi and links provided by him i was able to find out what caused the issue.
Main Link
Second one
And last which point the way to uninstall Windows Process Activation Service in Windows 10 pro not server one
Just to be sure I uninstalled:
Internet Information Services Hostable Web Core
I hope this answer would help someone in future.
Thanks again #LexLi for assistant.
Cheers!
I have a .bat file with the following line that runs appcmd to install the sites contained in sites.xml
%windir%\system32\inetsrv\appcmd add site /in < .\sites.xml
sites.xml contains the following
<?xml version="1.0" encoding="UTF-8"?>
<appcmd>
<SITE SITE.NAME="Default Web Site" SITE.ID="1" bindings="http/*:80:,net.tcp/808:*,net.pipe/*,net.msmq/localhost,msmq.formatname/localhost,https/*:443:" state="Started">
<site name="Default Web Site" id="1" serverAutoStart="true">
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
<binding protocol="net.tcp" bindingInformation="808:*" />
<binding protocol="net.pipe" bindingInformation="*" />
<binding protocol="net.msmq" bindingInformation="localhost" />
<binding protocol="msmq.formatname" bindingInformation="localhost" />
<binding protocol="https" bindingInformation="*:443:" />
</bindings>
<limits />
<logFile />
<traceFailedRequestsLogging />
<applicationDefaults />
<virtualDirectoryDefaults />
<application path="/">
<virtualDirectoryDefaults />
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" />
</application>
<application path="/MyWebsite" applicationPool="MyWebsite">
<virtualDirectoryDefaults />
<virtualDirectory path="/" physicalPath="D:\Projects\MySolution\DEV\Source\MyWebsite" />
</application>
</site>
</SITE>
</appcmd>
I need to make part of the virtualdirectory physicalpath D:\Projects\MySolution be whatever the currentdirectory is.
Is there any variable that I can insert in sites.xml to make that happen?
I'd like to do a URL rewrite in IIS where subdomain is rewritten. For example:
www.mycompany.com/api/v1.0 gets rewritten to api1.mycompany.com
www.mycompany.com/api/v2.0 gets rewritten to api2.mycompany.com
Note that I'd like to rewrite and not redirect, in other words, the URL in the browser remains www.mycompany.com/api/v1.0 and www.mycompany.com/api/v2.0.
Any request that doesn't fit the patterns above should continue to be processed by www.mycompany.com.
My understanding is the URL Rewrite 2.0 module alone isn't enough to make this happen, so I installed Application Request Routing 3.0. Here is the web.config for what I'm trying to do:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="API v1.0" stopProcessing="true">
<match url="^api/v1.0/(.*)$" />
<action type="Rewrite" url="http://api1.mycompany.com/{R:1}" />
</rule>
<rule name="API v2.0" stopProcessing="true">
<match url="^api/v2.0/(.*)$" />
<action type="Rewrite" url="http://api2.mycompany.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Once I installed Application Request Routing, I was able to get this to work, but only if www.mycompany.com is the Default Website for IIS. In other words, only if IIS is set up as so:
Default Website (www.mycompany.com)
The web.config for this site is shown above
api1.mycompany.com
api2.mycompany.com
My problem is that www.mycompany.com cannot be the Default Website (the Default Website is reserved by another site on the server). www.mycompany.com is just another web site just like api1.mycompany.com or api2.mycompany.com. Is there any way to get this to work without www.mycompany.com being the Default Website? Something like this?
Default Website (some another non-related website)
www.mycompany.com
The web.config for this site is as shown above
api1.mycompany.com
api2.mycompany.com
If you can change the C:\Windows\System32\inetsrv\config\applicationHost.config config file, you can put your rewrite configuration inside it.
I test locally and it works under IIS8 and ARR 3.0.
My applicationHost.config file look like this :
<system.webServer>
<rewrite>
<rules>
<rule name="API v1.0" stopProcessing="true">
<match url="^api/v1.0/(.*)$" />
<action type="Rewrite" url="http://api1.company.com/{R:1}" />
</rule>
<rule name="API v2.0" stopProcessing="true">
<match url="^api/v2.0/(.*)$" />
<action type="Rewrite" url="http://api2.company.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
<!-- ... --->
<webFarms>
<applicationRequestRouting>
<hostAffinityProviderList>
<add name="Microsoft.Web.Arr.HostNameRoundRobin" />
<add name="Microsoft.Web.Arr.HostNameMemory" />
</hostAffinityProviderList>
</applicationRequestRouting>
</webFarms>
<!-- ... --->
<system.applicationHost>
<sites>
<site name="Default Web Site" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:" />
</bindings>
</site>
<site name="company.com" id="2">
<application path="/" applicationPool="company.com">
<virtualDirectory path="/" physicalPath="C:\tmp\company.com\www" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:www.company.com" />
</bindings>
</site>
<site name="api1.company.com" id="3">
<application path="/" applicationPool="api1.company.com">
<virtualDirectory path="/" physicalPath="C:\tmp\company.com\api1" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:api1.company.com" />
</bindings>
</site>
<site name="api2.company.com" id="4">
<application path="/" applicationPool="api2.company.com">
<virtualDirectory path="/" physicalPath="C:\tmp\company.com\api2" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:api2.company.com" />
</bindings>
</site>
</sites>
</system.applicationHost>