I have a WCF service which is hosted in an exe using the ServiceHost class. I call it a "web service" because it's listening via https, so I can ping it from a web browser. (Sorry if not all my terms are precise.)
I would like to enable HSTS for this web service. I found that I can enable it by putting this into the Web.config:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000"/>
</customHeaders>
</httpProtocol>
<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>
</system.webServer>
But I don't have a Web.config, because the service is NOT hosted in IIS. I have tried to add this into the system.ServiceModel section but was ineffective. I'm not sure if the system.webServer section could be processed without IIS support or not. I'm also not sure if HSTS is a valid concept at all without IIS (or Apache).
All the articles I read so far, only described the IIS scenario.
https://www.hanselman.com/blog/how-to-enable-http-strict-transport-security-hsts-in-iis7
https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/hsts
https://www.forwardpmx.com/insights/blog/the-ultimate-guide-to-hsts-protocol/
So my question is: how can I enable the HSTS in this scenario?
Edit: my servicemodel config(edited to eclipse our product name)
<system.serviceModel>
<services>
<service behaviorConfiguration="AServiceBehavior" name="something.RemoteAccess.WebAccess.A.Core.A">
<endpoint address="" behaviorConfiguration="AEndpointBehaviour" binding="basicHttpBinding" bindingConfiguration="secureBasicHttpBinding" name="A" bindingNamespace="uri:something.RemoteAccess.WebAccess.A" contract="something.RemoteAccess.WebAccess.A.IService"/>
<host>
<baseAddresses>
<add baseAddress="https://*:4510/somethingWebAccess/A"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureBasicHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="AEndpointBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AServiceBehavior">
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>