Nginx

[Nginx] redirection error

오병문 2022. 4. 13. 16:51

아래와 같은 에러를 뱉고 있다면,

2022/03/09 07:47:47 [error] 1361#1361: *518 rewrite or internal redirection cycle while internally redirecting to "/index.php", 
client: 125.143.140.7, server: ec2-3-39-30-218.ap-northeast-2.compute.amazonaws.com, request: "GET /myPage 
HTTP/1.1", host: "ec2-3-39-30-218.ap-northeast-2.compute.amazonaws.com"

nginx 설정 중 location 부분을

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

아래와 같이 변경

location / {
    try_files $uri $uri/ /index.html?$query_string;
}

redirect가 일어날 때 index.php참조. 파일이 없으므로 500 에러 발생함

react는 root 페이지인 index.html?$query_string; 로 설정해야 함