-
Notifications
You must be signed in to change notification settings - Fork 7
munetic_proxy 설정
jolim edited this page Jan 17, 2022
·
1 revision
- Dockerfile
- envsubst.sh를
/docker-entrypoint.d
에 집어넣습니다./docker-entrypoint.d
안의 shell 파일들은 컨테이너 초기화 시 실행됩니다.
- envsubst.sh를
- envsubst.sh
- nginx 설정파일에서는 환경 변수가 치환되지 않습니다. templates 안의 파일을 변수치환하여
/etc/nginx/conf.d/default.conf
에 집어넣습니다. -
SERVER_NAME
이 localhost인 경우에는 로컬 환경에서 실행된 것으로 판단합니다. localhost.conf.template를 사용합니다.
- nginx 설정파일에서는 환경 변수가 치환되지 않습니다. templates 안의 파일을 변수치환하여
- templates
- 원래
/etc/nginx/conf.d/templates
에 마운트되는 폴더였습니다. 더 이상 마운트될 필요가 없습니다. 마운트되면 안됩니다. - default.conf.template
- 하단에서 설명
- localhost.conf.template
- https를 사용하지 않는 설정파일입니다.
- 원래
server {
listen 80;
server_name ${SERVER_HOST};
location /.well-known/acme-challenge/ { # certbot의 letsencrypt 인증을 위한 주소입니다. 해당 디렉토리 내부의 파일을 검사하여 인증을 합니다.
root /var/www/certbot;
}
location / { # 이외의 주소는 모두 https로 리다이렉트 합니다.
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl; # ssl 인증서를 사용하여 443번에서 listen합니다.
server_name ${SERVER_HOST};
resolver 127.0.0.11 valid=5s; # 도커 네트워크 내부의 기본 DNS 서버 주소를 사용합니다.
ssl_certificate /etc/letsencrypt/live/${SERVER_HOST}/fullchain.pem; # ssl 인증서 경로입니다.
ssl_certificate_key /etc/letsencrypt/live/${SERVER_HOST}/privkey.pem; # ssl 인증서 경로입니다.
include /etc/letsencrypt/options-ssl-nginx.conf; # ssl 인증서의 nginx 설정 경로입니다.
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# domain name을 ip 주소로 치환하기 위한 변수 설정. 직접 넣으면 domain name 치환이 되지 않습니다.
set $admin munetic_admin;
set $app munetic_app;
set $express munetic_express;
location /admin {
rewrite /admin(.*) /$1 break;
# 이 설정이 없으면 /admin/user는 http://$admin:4242/admin/user로 연결되게 됩니다.
# 이 설정이 있어야 /admin/user가 http://$admin:4242/user로 연결이 됩니다.
proxy_pass http://$admin:4242; # proxy_pass는 해당 주소에서 정보를 받아와 현재 주소로 서비스를 한다는 내용입니다.
}
location / {
proxy_pass http://$app:2424;
}
location /api {
# express는 내부에 루트 주소로 api를 붙여줬으므로 따로 붙여주지 않아도 됩니다.
proxy_pass http://$express:3030;
}
}