NancyFx / Nancy

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono
http://nancyfx.org
MIT License
7.15k stars 1.47k forks source link

503 Response when RewriteLocalhost=false #2925

Closed klym1 closed 5 years ago

klym1 commented 5 years ago

Prerequisites

Description

Trying to run self-hosted Nancy with RewriteLocalhost=false:

 _host = new NancyHost(new Uri("http://localhost:4444/"), 
    new HostBootstrapper(), 
    new HostConfiguration
                {
                    RewriteLocalhost = false
                });
_host.Start();

But it doesn't work, when I try to send some request it always responses with 503 Status:

GET / HTTP/1.1
Host: localhost:4444
User-Agent: insomnia/6.0.2
Accept: */*

HTTP/1.1 503 Service Unavailable
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 28 Aug 2018 16:40:50 GMT
Connection: close
Content-Length: 326

I don't want Nancy to listen on http://+:4444/ but simply on the IP I provide.

System Configuration

cloudhunter89 commented 5 years ago

Did you run the application once with RewriteLocalHost = true? Your problem is likely an issue with how Windows handles overlapping/conflicting http urlacl reservations. If there is an entries for both http://+:4444/ and http://localhost:4444/ Windows will return a 503 for the application listening on localhost. You can list all reservations with netsh http show urlacl. You can remove the wildcard reservation by running nesth http remove urlacl http://+:4444/ (from an administrator cmd prompt)

On Tue, Aug 28, 2018 at 10:50 AM Mykola Klymyuk notifications@github.com wrote:

Prerequisites

Description

Trying to run self-hosted Nancy with RewriteLocalhost=false:

_host = new NancyHost(new Uri("http://localhost:4444/"), new HostBootstrapper(), new HostConfiguration { RewriteLocalhost = false });_host.Start();

But it doesn't work, when I try to send some request it always responses with 503 Status:

GET / HTTP/1.1 Host: localhost:4444 User-Agent: insomnia/6.0.2 Accept: /

HTTP/1.1 503 Service Unavailable Content-Type: text/html; charset=us-ascii Server: Microsoft-HTTPAPI/2.0 Date: Tue, 28 Aug 2018 16:40:50 GMT Connection: close Content-Length: 326

I don't want Nancy to listen on http://+:4444/ but simply on the IP I provide. System Configuration

  • Nancy self-hosted
  • Nancy 1.4.4.0, Nancy.Hosting.Self 1.4.1.0
  • Windows 10 x64
  • .Net 4.7.1

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/NancyFx/Nancy/issues/2925, or mute the thread https://github.com/notifications/unsubscribe-auth/AEEilnKHS2zheNFCdydtfm4g2lKDqxrEks5uVXTagaJpZM4WQAYC .

-- Jonathon Koyle

klym1 commented 5 years ago

@cloudhunter89 Thanks for the answer. Yes, indeed, previously Nancy host was usually started with default RewriteLocalHost value (which is true). Who would expect that 503 is returned by OS! Removing the reservation has fixed the problem.