React,Node,JQuery,js
[Nginx] nginx.conf 에 Proxy 설정
bryan.oh
2020. 4. 3. 21:26
반응형
nginx.conf 에 Proxy 설정
upstream app {
server localhost:8080;
}
server {
listen 80;
localhost / {
root /app/build;
index index.html;
try_files $uri $uri/ /index.html;
}
localhost /api {
proxy_pass http://app;
}
}
localhost / app {
proxy_pass http://app;
}
proxy 설정이 없을 때는 그냥 localhost/api 이지만
위와 같은 설정이 있을 때는 해당 서버의 8080 포트로 넘긴다는 설정입니다.
예를들면 react 등 에서 fetch('/api/something')... 처럼 사용했을 때
경로에 /api 가 있으므로 proxy 설정에 걸려서
localhost:8080/api/something 과 같은 동작을 합니다.
728x90
반응형