Skip to content

Commit

Permalink
Merge pull request #6 from Team-hangout/build/5/proxy
Browse files Browse the repository at this point in the history
Build/5/proxy
  • Loading branch information
vixloaze authored Nov 23, 2023
2 parents 33594b2 + 9a63ab9 commit 4581efb
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 14 deletions.
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ services:
nginx:
container_name: nginx
image: nginx
build:
dockerfile: Dockerfile
context: ./nginx
ports:
- 80:80
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
depends_on:
- backend
networks:
Expand Down
4 changes: 4 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx
EXPOSE 80
RUN rm /etc/nginx/nginx.conf
COPY ./nginx.conf /etc/nginx/nginx.conf
12 changes: 0 additions & 12 deletions nginx/conf.d/app.conf

This file was deleted.

56 changes: 56 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024; # 각 워커 프로세스가 동시에 처리할 수 있는 연결 수를 1024로 제한
}

http {

include /etc/nginx/mime.types;
default_type application/octet-stream;

server_tokens off; # 헤더에 NGINX 버전을 숨김
keepalive_timeout 30s; # Nginx 웹 서버에서 클라이언트와의 연결을 유지하는 시간을 정의

log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

upstream api {
server backend:8080; # docker-compose에서 설정한 이름이 backend
}

upstream client {
server frontend:3000; # docker-compose에서 설정한 이름이 frontend
}

server {

listen 80;
access_log off;

location / {
proxy_pass http://client;
}

location /api {

proxy_http_version 1.1;
proxy_pass http://api;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

# location /api/v1 { #소셜 로그인 요청 API 추가 작성 (소셜 로그인 설정하실 때 필요하시면 쓰세요)
#
#
# }
}
}

0 comments on commit 4581efb

Please sign in to comment.