SharedIT | 묻고 답하기(AMP)

nginx에서 502 Bad Gateway 해결 방법좀 알려주세요 ㅠㅠ

CentOS release 6.9

nginx version: nginx/1.10.3

PHP 5.3.29 (PHP-FPM 5.3.3)



증상 : 특정 페이지에서 502  Bad Gateway 에러 출력


-- 로그1 -- (502 Bad Gateway 출력시)


2022/05/09 08:18:57 [error] 24612#0: *3827 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: action in /home/***/admin/html/index.php on line 20

PHP message: PHP Notice: Undefined index: talkDbCon in /home/***/admin/html/index.php on line 90

PHP message: PHP Notice: Undefined index: chatDbCon in /home/***/admin/html/index.php on line 95

PHP message: PHP Notice: Undefined variable: adminManagerLogMenu in /home/***/admin/html/include/left.php on line 164

PHP message: PHP Notice: Undefined index: page in /home/***/admin/html/content/memberList.php on line 20

PHP message: PHP Notice: Undefined variable: orderQuery in /home/***/admin/html/content/memberList.php on line 373

PHP message: PHP Notice: Undefined variable: pageNaviAddUrl in /home/***/admin/html/content/memberList.php on line 384

PHP message: PHP Notice: Undefined variable: first in /home/***/admin/html/class/page.class.php on line 121

PHP message: PHP Notice: Undefined variable: last in /home/***/admin/html/class/page.class.php on line 132

PHP message: PHP Notice: Undefined variable: pushQuery in /home/***/admin/html/content/memberList.php on line 479

PHP message: PHP Notice: Undefined index: 7dc3b25cdb14596b in /home/***/admin/html/common/function.php on line 523

PHP message: PHP Notice: Undefined index: 7dc3b25cdb14596b in /home/***/admin/html/common/function.php on line 525

PHP message: PHP Notice: Undefined index: endDate in /home/***/admin/html/common/function.php on line 532

PHP message: PHP Notice: Undefined index: endDate in /home/***/admin/html/common/function.php on line 539

PHP message: PHP Notice: Undefined index: 7dc3b25cdb14596b in /home/***/admin/html/common/function.php on line 565

PHP message: PHP Notice: Undefined variable: homeUrl in /home/***/admin/html/common/function.php on line 574

PHP message: PHP Notice: Undefined variable: homeUrl in /home/***/admin/html/common/function.php on line 578

PHP message: PHP Notice: Undefined index: 01034044783 in /home/***/admin/htm

2022/05/09 08:18:57 [error] 24612#0: *3827 upstream prematurely closed FastCGI stdout while reading response header from upstream, client: 175.198.102.194, server: admin.***.co.kr, request: "GET /?view=memberList&type=search&siteId=&mode=&searchType=mobile&query=01034044783&x=20&y=7&latitude=&longitude= HTTP/1.1", upstream: "fastcgi://unix://var/lib/php/php-fpm.sock:", host: "admin.***.co.kr", referrer: "http://admin.***.co.kr/?view=memberList"



-- 로그2 -- (정상 출력시)

2022/05/09 08:51:14 [error] 30837#0: *48816 FastCGI sent in stderr: "PHP message: PHP Notice: Undefined index: type in /home/***/admin/html/action/chat.php on line 4

PHP message: PHP Notice: Undefined index: lastRegDate in /home/***/admin/html/action/chat.php on line 5

PHP message: PHP Notice: Undefined index: moreYN in /home/***/admin/html/action/chat.php on line 6

PHP message: PHP Notice: Undefined index: targetid in /home/***/admin/html/action/chat.php on line 7

PHP message: PHP Notice: Undefined index: consultYN in /home/***/admin/html/action/chat.php on line 8

PHP message: PHP Notice: Undefined index: consultIdx in /home/***/admin/html/action/chat.php on line 9

PHP message: PHP Notice: Undefined index: msgType in /home/***/admin/html/action/chat.php on line 10

PHP message: PHP Notice: Undefined index: msg in /home/***/admin/html/action/chat.php on line 11

PHP message: PHP Notice: Undefined index: lastIdx in /home/***/admin/html/action/chat.php on line 12

PHP message: PHP Notice: Undefined index: idx in /home/***/admin/html/action/chat.php on line 13" while reading response header from upstream, client: 175.198.102.194, server: admin.***.co.kr, request: "POST / HTTP/1.1", upstream: "fastcgi://unix://var/lib/php/php-fpm.sock:", host: "admin.***.co.kr", referrer: "http://admin.***.co.kr/?view=memberList&type=search&siteId=&mode=&searchType=mobile&query=01034044783"



원인이 뭘까요? ㅜㅠ



Tags : 태그가 없습니다.

6개의 답변이 있습니다.

namsa87
  0 추천 | 2년 이하 전

자답으로

/etc/php.ini 에서 error_reporting = E_ALL & ~E_DEPRECATED 을 error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE 로 변경 후 정상적으로 작동되어 해결했습니다.




hgp33
  0 추천 | 2년 이하 전

정상일때와 오류상황일때 요청 방식이 다른거 같기는 한데 GET 방식으로 넘기면 파라메터 값을 URL로 넘기기때문에 사용자 입력값에 따라 (& , = , / ) 파라메터 인자와 값이 구별이 안되어 오류가 날수도 있습니다. 

넘어오는 파라메터 수신페이지에서 alert 찍어보세요..

wansoo
  0 추천 | 2년 이하 전

오류가 모두 Undefined variable, Undefined index 인데요.

PHP에서 변수 사용에 문제가 있는 것 같습니다.

사전 처리되어야할 모듈이 실행되지 않았거나, 초기화되지 않은 변수를 사용하거나 잘못된 값이 들어가 있는 변수를 사용함으로 인해 발생하는 오류로 보입니다.

지정하는 PHP 파일의 지정한 Line에 있는 지정한 변수값이 사용되기 전에 어떤 값을 가지고 있는지를 확인해 볼 필요가 있을 것 같고요.

상황에 따라 실행되지 못하고 누락되는 모듈이 있는게 아닌지도 확인해 볼 필요가 있을 것 같네요.

namsa87 | 2년 이하 전

액세스 로그를 확인했는데 특이한점을 발견했습니다.


[09/May/2022:11:49:48 +0900] "GET /?view=memberList&type=search&siteId=&mode=&searchType=mobile&query=010-3404-4783&x=25&y=7&latitude=&longitude= HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"


빨간색으로 표시한 부분때문에 오류가 나는걸로 추측이 되는데 저게 왜 넘어올까요??

wansoo | 2년 이하 전

모듈간에 자료 연동에 있어서 자료 구조가 서로 맞지 않는게 아닐까요?

예를 들어서 서브 모듈을 호출할때 자료 크기와 호출 당하는 모듈의 자료 크기가 다르다 거나...

전혀 엉뚱한 변수에 저장되어 있는 데이터 일부를 읽어 와서 처리하려는 형태의 오류로 보여 지네요.

wansoo
  0 추천 | 2년 이하 전

PHP message: PHP Notice: Undefined index: action in /home/***/admin/html/index.php


php에서 명령을 실행시키면서 경로를 잘못 지정한게 아닌가 싶어 보이네요.

/home/admin/html/index.php  처럼 경로가 지정되어야 할 것을

/home/***/admin/html/index.php 처럼 경로 문자열 중에 * 와일드 카드 문자를 잘못 입력한걸로 보여 집니다.

wansoo | 2년 이하 전

PHP 처리에 있어서 기본 작업 경로 지정에 잘못이 있는 것 같습니다.

경로 설정 변수에 들어가지 말아야 할 문자가 실수로 중간에 들어가 있는 것 같아 보이네요.

namsa87 | 2년 이하 전

/home/***/admin/html/index.php 에서의 와일드카드는 제가 로그에서 임의로 변경한 부분입니다.

회사 서비스명이 나와버려서 가렸어요

차바라기
  0 추천 | 2년 이하 전

http.conf환경 경로 확인해보세요

topkslee
  0 추천 | 2년 이하 전

확장자 지정이 안된 경우에 그럴수 있다고 하네요.

vi /etc/php/7.0/fpm/pool.d/www.conf

위 파일에서 security.limit_extensions 항목에 확장자 지정해서 한번 해보세요.

예)

security.limit_extensions = .php .php3 .php4 ........


수정 후 서비스 리스타트 해보세요.

systemctl restart php7.0-fpm.service (운영하는 서비스 이름)


해결되시길...