정적 파일을 찾지 못하는 Nginx 프록시에서 실행되는 ASP.NET Angular 앱

정적 파일을 찾지 못하는 Nginx 프록시에서 실행되는 ASP.NET Angular 앱

방금 Visual Studios에서 기본 응용 프로그램을 만들고 Nginx 프록시의 Ubuntu 서버에서 실행하려고 했습니다. 일단 시작하면 응용 프로그램이 실행되지만 프런트 엔드에서 정적 파일을 찾을 수 없으며 다음에 나열된 6개의 정적 파일에 대해 net::ERR_ABORTED를 반환합니다.이 화면 캡처.

내 Nginx 프록시는 다음과 같습니다.

location / {
            # Proxy for dotnet app
            proxy_pass http://localhost:5000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection keep-alive;
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
    }

SSL을 제공하기 위해 Certbot을 설정했습니다. Nginx 오류 파일에도 오류가 발생하지 않습니다.

정적 파일에서 net::ERR_ABORTED를 어떻게 해결할 수 있나요?

답변1

문제는 Nginx 서버가 루트 웹 디렉터리에서 파일을 찾을 수 없다는 것이었습니다. 다음 코드는 요청되면 지정된 디렉터리에서 정적 파일을 제공합니다.

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
    root   /path/to/static/content;
}

관련 정보