사용자 도구

사이트 도구


nginx:location

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
nginx:location [2012/11/07 17:43]
kwon37xi
nginx:location [2019/06/26 21:24] (현재)
kwon37xi
줄 6: 줄 6:
 <code> <code>
 location /images/something/ { location /images/something/ {
-    alias /var/www/something/+    alias /var/www/something/;
 } }
 </code> </code>
줄 25: 줄 25:
 </code> </code>
 웹폰트에 대해 ''Access-Control-Allow-Origin *'' 헤더를 추가하였다. 웹폰트에 대해 ''Access-Control-Allow-Origin *'' 헤더를 추가하였다.
 +
 +===== URL 중간에 정규표현식 있고, 특정 파일로 무조건 보내기  =====
 +<code>
 +location ~* ^/some/([0-9a-zA-Z\-_]+)/test {
 +  rewrite .* /somefile.html;
 +}
 +
 +location ~ /somefile.html {
 +  root /var/www/html;
 +}
 +</code>
 +
 +===== POST redirect =====
 +<code>
 +location ~* ^/some/test {
 +  return 302 /somefile.html;
 +}
 +
 +location ~ /somefile.html {
 +  root /var/www/html;
 +}
 +</code>
 +
 +===== Directory Listing 디렉토리 목록 =====
 +[[http://nginxlibrary.com/enable-directory-listing/|Enable directory listing]]
 +
 +<code>
 +location /somedir {
 +    autoindex on;
 +}
 +</code>
 +
 +===== internal =====
 +[[http://wiki.nginx.org/HttpCoreModule#internal|internal]]은 특정 location이 nginx 내부 요청에서만 유효하고 외부 요청에서는 404로 응답하도록 한다. 에러 페이지 등에 사용하면 좋다.
 +<code>
 +error_page 404 /404.html;
 +location  /404.html {
 +  internal;
 +}
 +</code>
 +
 +내부 요청은 다음과 같은 것들을 의미한다.
 +  * ''error_page''로 인해 발생한 요청
 +  * ''ngx_http_ssi_module'' 모듈의 ''include virtual'' 명령에 의한 요청
 +  * ''ngx_http_rewrite_module''의 ''rewrite'' 명령에 의해 변경된 요청
 +
 +
 +===== 참조 =====
 +  * [[https://ohgyun.com/480|꿀벌개발일지 :: Nginx HTTP Server - 4. HTTP 환경설정]] location 설정 패턴에 대한 설명이 자세함.
 +
nginx/location.1352277797.txt.gz · 마지막으로 수정됨: 2012/11/07 17:43 저자 kwon37xi