Skip to content

Commit

Permalink
feat: nginx 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
GiHwan2 committed Sep 28, 2024
1 parent 0b9ed00 commit 4018291
Showing 1 changed file with 53 additions and 58 deletions.
111 changes: 53 additions & 58 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,73 +4,68 @@ events {
worker_connections 1024;
}

# HTTP 서버 설정 (포트 80에서 HTTPS로 리디렉션)
server {
listen 80;
server_name floating.site www.floating.site;
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

charset utf-8;
server_tokens off;
client_max_body_size 1G;
sendfile on;
keepalive_timeout 65;

# HTTP -> HTTPS 리다이렉트
location / {
return 301 https://$host$request_uri;
}
server {
listen 80;
server_name floating.site www.floating.site;

# HTTP -> HTTPS 리다이렉트
location / {
return 301 https://$host$request_uri;
}

# Let's Encrypt 인증서 갱신을 위한 경로
location /.well-known/acme-challenge/ {
allow all;
root /var/www/certbot;
location /.well-known/acme-challenge/ {
allow all;
root /var/www/certbot;
}
}
}

# HTTPS 서버 설정 (포트 443에서 HTTPS로 서비스)
server {
listen 443 ssl;
server_name floating.site www.floating.site;
server {
listen 443 ssl;
server_name floating.site www.floating.site;

charset utf-8;
server_tokens off;
client_max_body_size 1G;
ssl_certificate /etc/ssl/certs/fullchain.pem;
ssl_certificate_key /etc/ssl/private/privkey.pem;

# SSL 설정
ssl_certificate /etc/ssl/certs/fullchain.pem;
ssl_certificate_key /etc/ssl/private/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

# API 요청은 백엔드 서버로 전달
location /api/ {
proxy_pass http://backend:8080;
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;
}
# API 요청은 백엔드 서버로 전달
location /api/ {
proxy_pass http://backend:8080;
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;
}

location /login/ {
proxy_pass http://backend:8080;
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;
}

; # 로그인 관련 요청
; location /login/ {
; proxy_pass http://backend:8080;
; 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;
; }
;
; # OAuth2 관련 요청
; location /oauth2/ {
; proxy_pass http://backend:8080;
; 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;
; }
location /oauth2/ {
proxy_pass http://backend:8080;
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;
}

# 정적 파일 서빙 (React 애플리케이션)
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
# 정적 파일 서빙
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
}

0 comments on commit 4018291

Please sign in to comment.