django rest framework로 api서버를 띄우고 nginx 웹 서버를 통해 연동해서 띄워보았다.
nginx 설정을 관리하는 파일. 리눅스에서 /etc/nginx
경로에 들어있다.
# 사용자계정명
user <사용자 계정명>;
http {
# 생략
# 로그파일 경로
access_log <your path>/access.log;
error_log <your path>/error.log;
# 프로젝트 설정파일(.conf) 경로
include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
}
프로젝트 설정을 관리하는 파일. 리눅스에서 /etc/nginx/conf.d
또는 /etc/nginx/sites-enabled
경로에 들어있다.
server {
# 포트
listen 9999;
server_name nicrealtest.ai;
charset utf-8;
# 프로젝트 경로
location /static/ {
root /home/manager/real/;
}
location / {
include proxy_params;
proxy_pass http://0.0.0.0:8000;
}
}
위와 같이 설정하고 나면 아래 명령어로 실행시켜주자. nginx는 gunicorn을 미들웨어로 하여 구동되기 때문에 gunicorn도 같이 실행시켜 주어야 작동된다.
sudo service gunicorn start
sudo service nginx start