본문 바로가기
Tool/Nginx

[NGINX] 3-3. Configuration-Variables 사용하기

by 건빵거늬 2021. 12. 18.

바보개발자님 블로그 먼저 보기

https://minholee93.tistory.com/entry/Nginx-Location-Block-Variables?category=926406 

 

[Nginx] Location Block & Variables

이전글에 이어서 Nginx의 configuartion에 대해 알아보도록 하겠습니다. 3. Location Blocks location은 specific uri에 대한 behavior를 정의하며 server 내부에 작성합니다. location block은 nginx.conf 에서..

minholee93.tistory.com

1. Buit-in Variables 사용해보기

built-in variables

2. If문 사용해보기

location context에서 if는 사용하지 않는 게 좋다
참고: https://www.nginx.com/resources/wiki/start/topics/depth/ifisevil/

1. apikey=1234 를 넘겨주지 않으면 401코드를 주기로 설정해놓는다

401 Unauthorized

Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.

2. apikey 없이 접속시
3. apikey = 1234 넣어서 접속시

이미지와 css파일에 접근하는 내부 request에는 apikey가 없기때문에 이렇게 이미지가 없고 css도 적용되지 않은 페이지가 렌더링 된다.

3. custom variable 사용해보기

댓글