How to hide my WCF service

I have a WCF service built into a windows service. It contacts localhost, but also accepts a connection from these kind of URLs: "http: // ip: port / ServiceName", how can I hide it from others and only allow connection to localhost.

Here is my service configuration

<system.serviceModel>
 <behaviors>
  <serviceBehaviors>
     <behavior name="Test.Service.ServiceBehavior">
         <serviceMetadata httpGetEnabled="true" /> 
         <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior>
  </serviceBehaviors>
 </behaviors>
 <services>
   <service behaviorConfiguration="Test.Service.ServiceBehavior" name="Test.Service.TestService">
      <endpoint address="localhost" binding="wsHttpBinding" contract="Test.Service.IService">
        <identity>
           <dns value="localhost" /> 
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      <host>
         <baseAddresses>
              <add baseAddress="http://localhost:8732/MyService/service" /> 
         </baseAddresses>
      </host>
  </service>
</services>
</system.serviceModel>
+3
source share
3 answers

To β€œhide” it, you need to disable metadata sharing, so you need to delete:

<serviceMetadata httpGetEnabled="true" /> 

from your service behavior, and you need to remove the mex endpoint:

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 

"" . - , netNamedPipeBinding, " " - .

IP- , , , ....

+6
+1

IIS, "*" "127.0.0.1"

0

Source: https://habr.com/ru/post/1776665/


All Articles