Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 2개 있습니다.)
(시리즈 글이 15개 있습니다.)
오류 유형: 2. [COM+] CreateObject 와 HTTP 500 - Internal server error
; https://www.sysnet.pe.kr/2/0/242

오류 유형: 111. IIS - 500.19 오류 (0x8007000d)
; https://www.sysnet.pe.kr/2/0/976

오류 유형: 201. ASP.NET 웹 사이트를 IIS 7 이상의 환경에서 호스팅할 때 500 오류 발생
; https://www.sysnet.pe.kr/2/0/1563

오류 유형: 219. IIS 500 Internal Server Error - Skydrive에 공유된 경우
; https://www.sysnet.pe.kr/2/0/1612

오류 유형: 232. IIS 500 Internal Server Error - NTFS 암호화된 폴더에 웹 애플리케이션이 위치한 경우
; https://www.sysnet.pe.kr/2/0/1722

오류 유형: 340. HTTP Error 500.23 - Internal Server Error
; https://www.sysnet.pe.kr/2/0/10997

오류 유형: 360. IIS - 500.19 오류 (0x80070021)
; https://www.sysnet.pe.kr/2/0/11061

개발 환경 구성: 307. ASP.NET Core Web Application을 IIS에서 호스팅하는 방법
; https://www.sysnet.pe.kr/2/0/11120

오류 유형: 580. HTTP Error 500.0/500.33 - ANCM In-Process Handler Load Failure
; https://www.sysnet.pe.kr/2/0/12064

오류 유형: 631. .NET Core 웹 응용 프로그램 오류 - HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process
; https://www.sysnet.pe.kr/2/0/12268

오류 유형: 662. ASP.NET Core와 500.19, 500.21 오류 (0x8007000d)
; https://www.sysnet.pe.kr/2/0/12356

개발 환경 구성: 635. 비주얼 스튜디오에서 실행하던 ASP.NET Core (.NET Framework) 응용 프로그램을 명령행에서 실행하는 방법 (2)
; https://www.sysnet.pe.kr/2/0/12955

.NET Framework: 1164. HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
; https://www.sysnet.pe.kr/2/0/12982

오류 유형: 884. HTTP 500.0 - 명령행에서 실행한 ASP.NET Core 응용 프로그램을 실행하는 방법
; https://www.sysnet.pe.kr/2/0/13488

오류 유형: 899. HTTP Error 500.32 - ANCM Failed to Load dll
; https://www.sysnet.pe.kr/2/0/13579




ASP.NET Core Web Application을 IIS에서 호스팅하는 방법

Visual Studio 2015에서 "ASP.NET Core Web Application(.Net Core)" 프로젝트 템플릿을 선택하고 "Web Application" 유형으로 만들면 기본적인 웹 응용 프로그램이 나옵니다.

빌드하고, IIS 웹 사이트로 연결했는데요. 웹 브라우저로 방문하니 다음과 같은 오류가 발생합니다.

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

Module
   IIS Web Core 

Notification
   Unknown 

Handler
   Not yet determined 

Error Code
   0x8007000d 

Requested URL
   http://localhost:8087/ 

More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error. 

이 오류가 났던 적이 있었군요. ^^

IIS - 500.19 오류 (0x8007000d)
; https://www.sysnet.pe.kr/2/0/976

즉, web.config 파일에 지정된 모듈이 인식되지 않았던 것인데요. 실제로 asp.net core 웹 응용 프로그램의 기본 web.config 파일을 보면,

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

AspNetCoreModule 모듈이 지정된 것을 볼 수 있습니다. 당연히 기본 설치된 Windows Server에는 관련 모듈이 없습니다. 따라서, IIS에서 .NET Core를 호스팅 할 수 있도록 부가 작업을 해야 합니다.

Install the .NET Core Windows Server Hosting bundle
; https://learn.microsoft.com/en-us/aspnet/core/publishing/iis

위의 글에 나온 것처럼, ".NET Core Windows Server Hosting bundle"을 설치하면 되는데요.

.NET Core Windows Server Hosting bundle (DotNetCore.1.1.0-WindowsHosting.exe)
; https://download.microsoft.com/download/F/6/E/F6ECBBCC-B02F-424E-8E03-D47E9FA631B7/DotNetCore.1.1.0-WindowsHosting.exe

위의 설치 파일은 ".NET Core Runtime"과 ".NET Core Library" 및 IIS에서 요청을 처리하는 ASP.NET Core 모듈을 설치합니다. 그런데, 이런 상태에서도 다음과 같은 오류를 내면서 실행이 안됩니다.

HTTP Error 502.5 - Process Failure 

Common causes of this issue: 
* The application process failed to start 
* The application process started but then stopped 
* The application process started but failed to listen on the configured port 

Troubleshooting steps: 
* Check the system event log for error messages 
* Enable logging the application process’ stdout messages 
* Attach a debugger to the application process and inspect 

이때의 이벤트 로그를 보면 다음과 같은 항목이 보입니다.

Log Name:      Application
Source:        IIS AspNetCore Module
Date:          2016-12-25 오후 8:27:18
Event ID:      1000
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      TESTPC
Description:
Application 'MACHINE/WEBROOT/APPHOST/COREWEBAPP' with physical root 'D:\temp\coreapp\' failed to start process with commandline '"%LAUNCHER_PATH%" %LAUNCHER_ARGS%', ErrorCode = '0x80070002 : 0.

보아하니, 이것은 web.config의 설정값입니다.

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>

이 설정으로 검색해 보면,

ASP.Net Core 1.0 RC2 : What are LAUNCHER_PATH and LAUNCHER_ARGS mentioned in web.config?
; http://stackoverflow.com/questions/37463186/asp-net-core-1-0-rc2-what-are-launcher-path-and-launcher-args-mentioned-in-web

web.config에 저런 식으로 processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"로 설정된 것은 Visual Studio 내에서만 유효한 것입니다. 따라서, Visual Studio에서 개발할 때는 저 설정으로 빌드/실행하는 것은 가능하지만 IIS 웹 서버로 배포할 때는 그에 맞게 web.config이 변경되어야 합니다. 바로 이 작업을, Visual Studio의 "Publish" 명령으로 하는 것입니다.

이를 위해, Visual Studio에서 해당 Core 웹 프로젝트를 우 클릭한 후 "Publish..." 메뉴를 선택해 줍니다.

aspnet_core_on_iis_1.png

그럼 배포(Publish) 마법사가 뜨는데, "Custom" 항목을 선택하고 뜨는 "New Custom Profile" 창에서 배포 설정을 특정할 이름을 (원하는 대로) 지정해 줍니다. (이 배포 이름으로 저장된 설정은 나중에 재사용이 가능합니다.)

aspnet_core_on_iis_2.png

그다음 배포 경로를 지정하고, (아래의 화면에서는 기본값 그대로 "/bin/Release/PublishOutput")

aspnet_core_on_iis_3.png

마지막 배포 설정을 명시해주고 "Publish" 버튼을 눌러주면,

aspnet_core_on_iis_4.png

./bin/Release/PublishOutput 폴더에 실제 IIS 웹 서버에 배포할 바이너리 이미지들이 생성됩니다. 이렇게 배포된 PublishOutput 폴더의 web.config을 보면 다음과 같은 내용을 담고 있습니다.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\WebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>
<!--ProjectGuid: 028962a2-4bfe-4352-8f7d-6ee7fb543516-->

보시는 것처럼 processPath가 "%LAUNCHER_PATH%"에서 "dotnet"으로, arguments는 "%LAUNCHER_ARGS%"에서 ".\WebApplication1.dll"로 바뀌었습니다. 이렇게 바뀌어야 정상적으로 IIS에서 ASP.NET Core Web Application이 동작합니다.



그러니까, 결국 IIS에서의 ASP.NET Core 웹 응용 프로그램 실행은 다음과 같은 구조를 갖게 됩니다.

aspnet_core_on_iis_5.png

재미있는 것은, 요청을 AspNetCoreModule의 handler에서 받기 때문에 요청까지는 IIS의 관리를 받는다는 것입니다. 이로 인해 "Web Garden"을 2개 이상으로 지정해도 동일한 w3wp.exe가 2개 뜨고 그 각각의 하위에 다시 dotnet.exe가 자식 프로세스로 연결됩니다. 물론, 포트 충돌 문제는 없습니다. 이때의 dotnet.exe에 있는 ASP.NET Core 웹 응용 프로그램은 포트를 점유하지 않고 요청만 처리해 주는 별도 프로세스로 동작하는 것뿐입니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 8/10/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 46  47  48  49  50  51  52  53  [54]  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12278정성태7/23/20209454VS.NET IDE: 149. ("Binary was not built with debug information" 상태로) 소스 코드 디버깅이 안되는 경우
12277정성태7/23/202010894개발 환경 구성: 498. DEVPATH 환경 변수의 사용 예 - .NET Reflector의 (PDB 연결이 없는) DLL의 소스 코드 디버깅
12276정성태7/23/202010087.NET Framework: 930. 개발자를 위한 닷넷 어셈블리 바인딩 - DEVPATH 환경 변수
12275정성태7/22/202012640개발 환경 구성: 497. 닷넷에서 접근해보는 InterSystems의 IRIS Data Platform 데이터베이스파일 다운로드1
12274정성태7/21/202012020개발 환경 구성: 496. Azure - Blob Storage Account의 Location 이전 방법 [1]파일 다운로드1
12273정성태7/18/202013647개발 환경 구성: 495. Azure - Location이 다른 웹/DB 서버의 경우 발생하는 성능 하락
12272정성태7/16/20208656.NET Framework: 929. (StrongName의 버전 구분이 필요 없는) .NET Core 어셈블리 바인딩 규칙 [2]파일 다운로드1
12271정성태7/16/202010715.NET Framework: 928. .NET Framework의 Strong-named 어셈블리 바인딩 (2) - 런타임에 바인딩 리디렉션파일 다운로드1
12270정성태7/16/202011539오류 유형: 633. SSL_CTX_use_certificate_file - error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
12269정성태7/16/20208553오류 유형: 632. .NET Core 웹 응용 프로그램 - The process was terminated due to an unhandled exception.
12268정성태7/15/202010705오류 유형: 631. .NET Core 웹 응용 프로그램 오류 - HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process
12267정성태7/15/202012372.NET Framework: 927. C# - 윈도우 프로그램에서 Credential Manager를 이용한 보안 정보 저장파일 다운로드1
12266정성태7/14/202010075오류 유형: 630. 사용자 계정을 지정해 CreateService API로 서비스를 등록한 경우 "Error 1069: The service did not start due to a logon failure." 오류발생
12265정성태7/10/20209232오류 유형: 629. Visual Studio - 웹 애플리케이션 실행 시 "Unable to connect to web server 'IIS Express'." 오류 발생
12264정성태7/9/202018297오류 유형: 628. docker: Error response from daemon: Conflict. The container name "..." is already in use by container "...".
12261정성태7/9/202011204VS.NET IDE: 148. 윈도우 10에서 .NET Core 응용 프로그램을 리눅스 환경에서 실행하는 2가지 방법 - docker, WSL 2 [5]
12260정성태7/8/20209605.NET Framework: 926. C# - ETW를 이용한 ThreadPool 스레드 감시파일 다운로드1
12259정성태7/8/20209139오류 유형: 627. nvlddmkm.sys의 BAD_POOL_HEADER BSOD 문제 [1]
12258정성태7/8/202012305기타: 77. DataDog APM 간략 소개
12257정성태7/7/20209338.NET Framework: 925. C# - ETW를 이용한 Monitor Enter/Exit 감시파일 다운로드1
12256정성태7/7/20209747.NET Framework: 924. C# - Reflection으로 변경할 수 없는 readonly 정적 필드 [4]
12255정성태7/6/202010178.NET Framework: 923. C# - ETW(Event Tracing for Windows)를 이용한 Finalizer 실행 감시파일 다운로드1
12254정성태7/2/202010022오류 유형: 626. git - REMOTE HOST IDENTIFICATION HAS CHANGED!
12253정성태7/2/202011095.NET Framework: 922. C# - .NET ThreadPool의 Local/Global Queue파일 다운로드1
12252정성태7/2/202013067.NET Framework: 921. C# - I/O 스레드를 사용한 비동기 소켓 서버/클라이언트파일 다운로드2
12251정성태7/1/202011035.NET Framework: 920. C# - 파일의 비동기 처리 유무에 따른 스레드 상황 [1]파일 다운로드2
... 46  47  48  49  50  51  52  53  [54]  55  56  57  58  59  60  ...