모바일 도메인을 분리해달라는 요청으로 nginx 추가 및 설정하고 기존 3000 포트를 80으로 변경함
FROM public.ecr.aws/kimchanhyung98/node18:latest
LABEL maintainer="kimchanhyung98 <kimchanhyung98@gmail.com>"
# Set working directory
WORKDIR /var/www
# Copy code to /var/www
COPY --chown=www:www-data . /var/www
# Install packages & build
RUN npm cache clean -f
RUN npm install
RUN npm run build
RUN cp docker/nginx.conf /etc/nginx/sites-enabled/default
EXPOSE 80
ENTRYPOINT ["sh", "/var/www/docker/run.sh"]
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "1234567890.dkr.ecr.ap-northeast-2.amazonaws.com/frontend:latest",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "80",
"HostPort": "80"
}
]
}
server {
listen 80;
# server_name _;
server_name fortune.example.com
charset utf-8;
location ~ ^/m(/.*)?$ {
return 301 <http://m.fortune.example.com$1>;
}
location / {
proxy_pass <http://127.0.0.1:3000/>;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 80;
server_name m.fortune.example.com;
charset utf-8;
location = / {
proxy_pass <http://127.0.0.1:3000/m>;
}
# Handle the specific _next path without the m prefix
location ~ ^/_next/ {
proxy_pass <http://127.0.0.1:3000>;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Redirect requests starting with /m to /
location ~ ^/m(/?)(.*)$ {
return 301 $scheme://$host/$2;
}
location / {
proxy_pass <http://127.0.0.1:3000/m/>;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}