Self hosted OWIN and urlacl

前端 未结 3 1517
北荒
北荒 2020-11-29 05:53

I\'ve created a self hosted Nancy/SignalR application self-hosted in OWIN using Microsoft.Owin.Host.HttpListener and Microsoft.Owin.Hosting

<
相关标签:
3条回答
  • 2020-11-29 06:23

    I spend many hours solving similar issue on Windows 8.1.

        StartOptions options = new StartOptions();
    
        options.Urls.Add("http://localhost:9000");
        options.Urls.Add("http://127.0.0.1:9000");
        options.Urls.Add("http://192.168.0.102:9000");
        options.Urls.Add(string.Format("http://{0}:9000", Environment.MachineName));
    
        WebApp.Start<Startup>(options);
    

    I could not listen or was getting 503 error...

    If you want to listen on several IP addresses, each address needs its own urlacl record:

    Does NOT work:

        netsh http>add urlacl http://+:9000/ user=EveryOne    
    

    OK:

        netsh http>add urlacl http://localhost:9000/ user=EveryOne
        netsh http>add urlacl http://127.0.0.1:9000/ user=EveryOne
        etc.
    

    After adding reservation for each address individually, everything works fine.

    0 讨论(0)
  • 2020-11-29 06:25

    Thanks to the info that @kay.one provided I was able to access my self-hosted Web API 2.2 (OWIN/Katana, console app) from the same machine via IP address. However just consolidate it into a simple step-by-step:

    1. In Main of Program.cs (for console app): WebApp.Start<Startup>("http://*:8080");
    2. From Windows Command Prompt (run as Administrator) enter netsh http add urlacl http://*:8080/ user=EVERYONE
    3. Go to Windows Firewall with Advanced Security and add an Inbound Rule that opens up TCP port 8080

    You should then be able to access from another machine using IP address or computer name.

    Disclaimer: I'm not a security expert so I don't know the security implications of doing this.

    0 讨论(0)
  • 2020-11-29 06:28

    so it turns out you need to pass in a url into StartOptions in the same format as the urlacl.

    Changing the start options to the code below fixed the problem. now the app is accessible across the network.

      var options = new StartOptions("http://*:8989")
      {
          ServerFactory = "Microsoft.Owin.Host.HttpListener"
      };
    
    0 讨论(0)
提交回复
热议问题