Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build/5/proxy #6

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 추가 작성 (소셜 로그인 설정하실 때 필요하시면 쓰세요)
#
#
# }
}
}