문서의 이전 판입니다!
alias 는 특정 URL이 서빙할 파일 경로를 변경하는 역할을 한다. root와는 역할이 다르다.
location /images/something/ { alias /var/www/something/ }
이 상태에서 http://example.com/images/something/somepath/myfile.png
의 실제 파일상 경로는 /var/www/something/sompath/myfile.png
가 된다. 중간에 location에 기술된 /images/something
은 경로를 구성할 때 빠진다.
반면에 root /var/www/something
으로 구성했다면 실제 파일상 경로는 /var/www/something/images/something/somepath/myfile.png
가 된다.
$uri
변수로 파일 확장자를 확인할 수 있다. $uri
는 쿼리 파라미터는 모두 제거한 파일까지의 경로이다.
location / { if ($uri ~ ^(.+)\.(eot|ttf|woff)$) { add_header Access-Control-Allow-Origin *; } }
웹폰트에 대해 Access-Control-Allow-Origin *
헤더를 추가하였다.
location ^~ /some/([0-9a-zA-Z\-_]+)/test { root /var/html; rewrite .* /somefile.html; }