2013-10-04 1 views
0

GET //srv/app/static/index.html으로 다시 쓰려고합니다. 나는이 몇 가지 지침을 가까이 해요 : I GET /static이 nginx를가 /srv/app/static/index.html에서 파일을 제공하며, 나는 행복 해요nginx는 어떻게 위치 블록에 파일 경로를 구성합니까?

root /srv/app/static; 
location /static { 
    alias /srv/app/static; 
} 
location =/{ 
    alias /srv/app/static/index.html; 
} 

그래서.

하지만일 때, nginx는 404를 반환합니다. 로그를 확인하면 파일 /srv/app/static/index.htmlindex.html (sic)에 액세스하려고하는 것 같습니다. 왜 여분 index.htmlalias에 주어진 경로에 집어 넣을까요? 내가

location =/{ 
    index index.html; 
    alias /srv/app/static/; 
} 

해당 지침을 변경하면

오류 로그는 /srv/app/static에서 최종 c 문자를 제거, /srv/app/stati (원문에 액세스하려고 보여줍니다 여기에 무슨

편집 :.?

:

나는이 같은 rewrite를 사용하여 원하는 동작을 얻을 수 있습니다

그러나 나는 alias이 더 공감적이고 관용적이라고 생각합니다.

답변

0

root을 이미 설정 했으므로 alias이 필요하지 않습니다.

당신은 재미있는 문제에 관해서는 단지

location =/{ 
    index index.html; 
} 

와 동일한 결과를 얻을 수는 documentation에서 보면 기본적으로

, 이것은 의미 언급 그와

location =/{ 
    alias /srv/app/static/index.html; 
} 

/에 액세스하면 실제로 /srv/app/static/index.html에 액세스하려고 시도합니다. ctory. 나는 nginx가 nginx.conf의 일부로 index.html을 추가한다고 가정한다.

오류 로그에 /srv/app/stati을 얻는 것에 관해서는 잘 모르겠습니다. 아마도 전체 로그 항목을 붙여 넣을 수 있습니까?

관련 문제