NGINX 기본 개념 잡기 :: 행복한 프로그래머

posted by 쁘로그램어 2018. 8. 9. 14:54

# server 블록

server 블록은 하나의 웹사이트를 선언하는데 사용된다. 가상 호스팅(Virtual Host)의 개념이다.

예를들어 하나의 서버로 http://opentutorials.org 과 http://egoing.net 을 동시에 운영하고 싶은 경우 사용할 수 있는 방법이다.

가상 호스팅에 대한 자세한 내용은 가상 호스팅 수업을 참고하자. 


# location 블록

location 블록은 server 블록 안에 등장하면서 특정 URL을 처리하는 방법을 정의한다.

이를테면 http://opentutorials.org/course/1 과 http://opentutorials.org/module/1 로 접근하는 요청을 다르게 처리하고 싶을 때 사용한다. 


# 재작성 (rewrite)

재작성(Rewrite)이란 요청을 통해서 주어진 URL의 규칙을 변경해서 웹서비스를 보다 유연하게 만드는 방법이다.


# 설정 리로드

sudo service nginx reload;


# 변수

http://opentutorials.org:80/production/module/index.php?type=module&id=12


$host : opentutorials.org

$uri : /production/module/index.php

$args : type=module&id=12

server_addr : 115.68.24.88

server_name : localhost

server_port : 80

server_protocol : HTTP/1.1

$arg_type : module

$request_uri : /production/module/index.php?type=module&id=12

$request_filename : /usr/local/nginx/html/production/module/index.php


# 리버스프록시

두번째 역할은 리버스 프록시(reverse proxy)인데, 한마디로 말하면 클라이언트는 가짜 서버에 요청(request)하면, 프록시 서버가 배후 서버(reverse server)로부터 데이터를 가져오는 역할을 한다. 


upstream, rewrite, proxy_pass에 대한 학습이 필요하다!!!!

proxy, reverse proxy에 대한 학습도 필요함!!

(학습해서 다시 정리 필요)


# 참고 사이트

https://opentutorials.org/module/384/3462

http://whatisthenext.tistory.com/123

https://sarc.io/index.php/nginx/61-nginx-nginx-conf

http://ohgyun.com/479

https://extrememanual.net/10140

https://brunch.co.kr/@elijah17/19

https://www.yongbok.net/blog/tag/%ED%94%84%EB%B9%84-nginx-%EC%84%A4%EC%B9%98/

https://www.joinc.co.kr/w/man/12/proxy