server {
listen 80;
server_name localhost;
# 기본 root 경로 설정
root "F:\프로젝트 모음\frontend\RTLS_front\front\build";
# static 폴더에 대한 별도 location 설정
location /static/ {
alias "F:\프로젝트 모음\frontend\RTLS_front\front\build\static/";
try_files $uri =404;
}
# 기본 location 설정
location / {
try_files $uri $uri/ /index.html;
index index.html;
}
# manifest, favicon 등을 위한 설정
location ~* \.(json|ico|png)$ {
try_files $uri =404;s
}
location /api/ {
proxy_pass http://localhost:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
1. 서버 루트 경로를 설정 // index.html 설정
2. static경로를 설정해주어야 js,css 파일이 적용된다
3. location /api/ ... proxy_pass http://localhost:8081; 설정으로 백엔드로 프록시 패스 해준다 (각자 경로에 맞게 지정)