리버스 프록시 세팅

location /server/ {
    proxy_pass <http://backend>:${PORT};
    proxy_redirect default;
    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;
    proxy_set_header X-Forwarded-Host $server_name;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    # URI의 /server 부분 제거
    rewrite ^/server/(.*) /$1 break;
}

해당 nginx config은 /server로 들어온 요청에 대해 backend로 프록시 하며 각종 헤더를 세팅하는 과정이다.

예를들어 /server/auth로 요청이 들어온 경우에 backend:${PORT}/auth로 프록시한다.

location / {
    root /usr/share/nginx/html; 
    try_files $uri $uri/ /index.html;
}

이 config은 / 로 들어온 요청에 대해 /usr/share/nginx/html에서 파일을 찾는 것이다.

예를들어 /image.jpg로 요청이 들어온 경우 /usr/share/nginx/html/image.jpg를 찾게 된다.

만약 / 로만 URL이 구성된 경우에 index.html을 찾아서 제공한다.