Development Tip

잘못된 요청-잘못된 호스트 이름 IIS7

yourdevel 2020. 10. 18. 19:39
반응형

잘못된 요청-잘못된 호스트 이름 IIS7


포트 8080에서 웹 앱을 사용하려고하면 다음 오류가 발생합니다.

잘못된 요청-잘못된 호스트 이름
HTTP 오류 400. 요청 호스트 이름이 잘못되었습니다.

이 문제를 어디에서 진단해야할지 모르겠습니다.


바인딩이 IIS인지 확인 했습니까? (inetmgr.exe) 8080에서 모든 호스트 이름을 허용하도록 등록되지 않았을 수 있습니다.

예를 들어 mysite.com:8080에 대해 설정하고 localhost : 8080에 도달하면 IIS는 요청을 받지만 호스트 이름 바인딩이 일치하지 않으므로 거부합니다.

그 외에 서버에서 IIS 로그 (C : \ inetpub \ logs \ wmsvc #)를 확인하고 요청이 표시되는지 확인해야합니다. 그러면 클라이언트 또는 서버 자체에 문제가 있는지 알 수 있습니다.


FWIW, 호스트 이름 / ip에 대한 요청 만 허용하려면 다음과 같이 바인딩을 설정할 수 있습니다.

<binding protocol="http" bindingInformation="*:80:*" />

이 바인딩을 사용하여 IE6로 VM을로드 한 다음 내 애플리케이션을 디버깅 할 수 있습니다.


편집 : IIS Express를 사용하여 디버깅하는 동안이 옵션 구성 파일의 기본 위치는 다음과 같습니다.

C:\Users\{User}\Documents\IISExpress\config\applicationhost.config

Microsoft 의이 페이지에서는 로컬 네트워크의 다른 컴퓨터에서 IIS Server Express에 대한 액세스를 설정하는 방법을 설명합니다.

간단히 말해서 :

1) 관리자 권한이있는 명령 프롬프트에서 :

netsh http add urlacl url=http://[your ip address]:8181/ user=everyone

2) 고급 보안이 포함 된 Windows 방화벽에서 포트 8181에 대한 새 인바운드 규칙을 만들어 외부 연결을 허용합니다.

3) applicationhost.config에서 프로젝트의 노드에 다음을 추가하십시오.

<binding protocol="http" bindingInformation="*:8181:[your ip address]" />

추가하지 마십시오 (다른 답변에서 제안한대로) :

<binding protocol="http" bindingInformation="*:8181:*" />

위의 와일드 카드 바인딩은 http://192.168.1.6:8181/


그래서 IIS 관리자의 웹 사이트로 이동하여 사이트 바인딩의 호스트 이름을 localhost에서 *로 변경하여이 문제를 해결했습니다. 즉시 작업을 시작했습니다.

IIS의 사이트 바인딩


IPv6 주소에도 바인딩하는 것을 잊지 마십시오! localhost를 사용하여 127.0.0.1에 사이트를 추가하려고했는데 잘못된 요청 / 잘못된 호스트 이름 오류가 발생했습니다. localhost를 ping했을 때 IPv6가 활성화 되었기 때문에 :: 1로 해결되었으므로 문제를 해결하기 위해 추가 바인딩을 추가해야했습니다.

IIS 사이트 바인딩


이 slove 내 문제 :
(나쁜 영어에 대해 죄송합니다)
1.) cmd를 관리자로 열고 명령을 실행하십시오 (대괄호 제외) : netsh http add urlacl url = http : // [ip adress] : [port] / user = 여러분

2.) documents / iisexpress / config / applicationhost.config 및 폴더 (숨겨진 폴더) .vs / config / applicationhost.config의 루트 프로젝트 폴더에서 "site"태그에 행을 추가해야합니다.

3.) open "internet information services (iis) manager", (if is not find: in serch in tasckbar write "Turn Window features on or off" and open resulet and then check the checkbox "internet information service" and its install that) in left screen click computer-name-->Sites-->Default Web Site and then click in right screen "Binding" click Add button wirte what yuo need and press OK.

4.) open "Windows Firewall With Advanced Security", in left screen press "Inbound Rules" and then press in right screen "New Rule..." check port and press Next, check TCP and your port and press Next, check "Allow the connaction" and press Next, check all checkbox and press Next, wirte name and press Finish.

done.


들어 Visual Studio 2017Visual Studio 2015, IIS Express설정이 숨겨져에 저장되어있는 .vs디렉토리 경로가이 같은 것입니다 .vs\config\applicationhost.config, 의지 작업을 아래와 같이 바인딩 추가

<bindings>
    <binding protocol="http" bindingInformation="*:8802:localhost" />
    <binding protocol="http" bindingInformation="*:8802:127.0.0.1" />
</bindings>

이것이 당신의 문제인지 확실하지 않지만 그의 컴퓨터에서 그의 웹 응용 프로그램에 액세스하려고 시도 하고이 문제가있는 사람에게는 다음과 같습니다.

외부 IP 주소가 아닌 127.0.0.1(일명 localhost)에 연결하고 있는지 확인하십시오 .

귀하의 URL은 무언가 같이해야 http://localhost:8181/또는 http://127.0.0.1:8181없습니다 http://YourExternalIPaddress:8181/ .


추가 정보 :
이것이 작동하는 이유는 방화벽이 사용자의 요청을 차단할 수 있기 때문입니다. OS의 방화벽이 될 수 있으며 라우터가 될 수 있습니다.

When you connect to your external IP address, you connect to you from the internet, as if you were a stranger (or a hacker).
However when you connect to your localhost, you connect locally as yourself and the block is obviously not needed (& avoided altogether).


You can use Visual Studio 2005/2008/2010 CMD tool. Run it as admin, and write

aspnet_regiis -i

At last I can run my app successfully.


Check your local hosts file (C:\Windows\System32\drivers\etc\hosts for example). In my case I had previously used this to point a URL to a dev box and then forgotten about it. When I then reused the same URL I kept getting Bad Request (Invalid Hostname) because the traffic was going to the wrong server.


I got this error when I tried to call a webservice using "localhost". I fixed it by using the actual IP instead (192.168...)


msdeploy를 사용하여 응용 프로그램을 새 서버에 복사 한 후에도 동일한 오류가 발생했습니다. 바인딩이 여전히 이전 서버의 IP 주소를 사용하고 있음이 밝혀졌습니다. 따라서 IIS 바인딩에서 IP 주소를 다시 확인하십시오. (사실 이후에 명백해 보이지만 즉시 확인하지 않았습니다).


제공하는 정확한 URL을 다시 확인하세요. 이 오류는 ASP.NET에 정의 된 경로 접두사를 놓 쳤기 때문에 요청을 라우팅 할 위치를 알지 못했습니다.


IIS가 포트를 수신하는지 확인하십시오.

제 경우에는 이것이 문제였습니다. 그래서 내 포트를 8083과 같은 다른 것으로 변경해야했고이 문제가 해결되었습니다.

참고 URL : https://stackoverflow.com/questions/4831097/bad-request-invalid-hostname-iis7

반응형