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

비밀번호

댓글 작성자
 




[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13601정성태4/19/2024214닷넷: 2243. C# - PCM 사운드 재생(NAudio)파일 다운로드1
13600정성태4/18/2024285닷넷: 2242. C# - 관리 스레드와 비관리 스레드
13599정성태4/17/2024337닷넷: 2241. C# - WAV 파일의 PCM 사운드 재생(Windows Multimedia)파일 다운로드1
13598정성태4/16/2024359닷넷: 2240. C# - WAV 파일 포맷 + LIST 헤더파일 다운로드1
13597정성태4/15/2024440닷넷: 2239. C# - WAV 파일의 PCM 데이터 생성 및 출력파일 다운로드1
13596정성태4/14/2024808닷넷: 2238. C# - WAV 기본 파일 포맷파일 다운로드1
13595정성태4/13/2024926닷넷: 2237. C# - Audio 장치 열기 (Windows Multimedia, NAudio)파일 다운로드1
13594정성태4/12/20241021닷넷: 2236. C# - Audio 장치 열람 (Windows Multimedia, NAudio)파일 다운로드1
13593정성태4/8/20241051닷넷: 2235. MSBuild - AccelerateBuildsInVisualStudio 옵션
13592정성태4/2/20241207C/C++: 165. CLion으로 만든 Rust Win32 DLL을 C#과 연동
13591정성태4/2/20241169닷넷: 2234. C# - WPF 응용 프로그램에 Blazor App 통합파일 다운로드1
13590정성태3/31/20241073Linux: 70. Python - uwsgi 응용 프로그램이 k8s 환경에서 OOM 발생하는 문제
13589정성태3/29/20241143닷넷: 2233. C# - 프로세스 CPU 사용량을 나타내는 성능 카운터와 Win32 API파일 다운로드1
13588정성태3/28/20241197닷넷: 2232. C# - Unity + 닷넷 App(WinForms/WPF) 간의 Named Pipe 통신파일 다운로드1
13587정성태3/27/20241156오류 유형: 900. Windows Update 오류 - 8024402C, 80070643
13586정성태3/27/20241299Windows: 263. Windows - 복구 파티션(Recovery Partition) 용량을 늘리는 방법
13585정성태3/26/20241096Windows: 262. PerformanceCounter의 InstanceName에 pid를 추가한 "Process V2"
13584정성태3/26/20241049개발 환경 구성: 708. Unity3D - C# Windows Forms / WPF Application에 통합하는 방법파일 다운로드1
13583정성태3/25/20241158Windows: 261. CPU Utilization이 100% 넘는 경우를 성능 카운터로 확인하는 방법
13582정성태3/19/20241420Windows: 260. CPU 사용률을 나타내는 2가지 수치 - 사용량(Usage)과 활용률(Utilization)파일 다운로드1
13581정성태3/18/20241588개발 환경 구성: 707. 빌드한 Unity3D 프로그램을 C++ Windows Application에 통합하는 방법
13580정성태3/15/20241138닷넷: 2231. C# - ReceiveTimeout, SendTimeout이 적용되지 않는 Socket await 비동기 호출파일 다운로드1
13579정성태3/13/20241494오류 유형: 899. HTTP Error 500.32 - ANCM Failed to Load dll
13578정성태3/11/20241629닷넷: 2230. C# - 덮어쓰기 가능한 환형 큐 (Circular queue)파일 다운로드1
13577정성태3/9/20241876닷넷: 2229. C# - 닷넷을 위한 난독화 도구 소개 (예: ConfuserEx)
[1]  2  3  4  5  6  7  8  9  10  11  12  13  14  15  ...