nginx가 client의 정적 빌드 파일을 실행해주고, 서버와의 proxy 서버 역할을 해준다.
(서버는 pm2로 함께 띄워놔야함)
실행
systemctl stop nginx
systemctl start nginx
nginx -s reload //서버를 끄지않고 설정만 리로드
nginx error log
/var/log/nginx/error.log
myapp.conf
server {
listen 80;
location / {
root /root/sool/client/build;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass <http://localhost:5000>;
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;
}
location ~* \\.io {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy false;
proxy_pass <http://localhost:5000>;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}