API 요청을 백엔드에 전달하려고 합니다.NGINX 리버스 프록시.
언제, 나는 get 요청을 보낸다/api/testdata, 다음으로 요청을 보냅니다.{frontendURL}/api/testData이는 301(리디렉션) 상태 코드로 반환됩니다. 그 후 요청을 올바른 URL로 리디렉션합니다.{backendURL}/api/testData.
nginx 구성:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/nginx/html;
server_name _;
location /health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 '{"status":"Healthy"}';
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /api {
proxy_pass http://localhost:3001;
proxy_redirect off;
}
요청이 하나만 나가도록 리디렉션 요청을 어떻게든 막을 수 있나요? 아니면 이것이 정상적인 행동입니까?