잠시만 기다려 주세요

     '시장이나 돌면서 가짜 민생 외치는 이재명을 규탄한다. 싸우지 않을 거면 내려와라... 거기는 당신의 방탄이나 하는 자리가 아니다.'
전체검색 :  
이번주 로또 및 연금번호 발생!!   |  HOME   |  여기는?   |  바다물때표   |  알림 (24)  |  여러가지 팁 (1107)  |  추천 및 재미 (165)  |  자료실 (25)  |  
시사, 이슈, 칼럼, 평론, 비평 (923)  |  끄적거림 (143)  |  문예 창작 (719)  |  바람 따라 (75)  |  시나리오 (760)  |  드라마 대본 (248)  |  
살인!


    리눅스 서버

리눅스 서버 - 502 bad gateway using Nginx
이 름 : 바다아이   |   조회수 : 12124         짧은 주소 : https://www.bada-ie.com/su/?251591803327

Many times we can browse the web and find a 502 bad gateway error at Nginx.   There are a few reasons why you will find this message in  your webserver log, and here we will teach you how to fix it.

When you will find 502 bad gateway error:

  1. Nginx running as proxy for Apache web server.
  2. Nginx running with PHP-FPM daemon.
  3. Nginx running with other services as gateway.
  4. Bad buffering/timeout configuration.

Before getting deep into all of this options, you must understand what does the error message means. So, the error it’s a 502 number and it’s happening at the gateway. What the hell is a gateway? In simple words, a gateway, is like an access point, a bridge that communicate one service with another, in this case the gateway can be a service/application that is working and recieving requests from Nginx web server.

Now, let’s explore each one of this reasons to understand the 502 bad gateway message:

  1. Nginx as Proxy for Apache: in this case, the gateway is Apache. When you use Nginx as proxy for Apache, if apache dies or it’s not well configured, it can cause this 502 error. How to fix it? Most of the times, restarting apache web server will get rid of this, but you must check the log files to know why exactly this was caused.
  2. Nginx with PHP-FPM: same as Apache example, let’s imagine your php daemon stop working, or get’s overloaded by requests, it will not work properly and the all the php requests from nginx would not be served, so, an error will appear. How to fix it? Restart php-fpm daemon and check the logs.
  3. Nginx with other services/apps: try restarting the other service behind nginx and explore the logs to find the reason why it happened.

Other quick solutions:

1) Increase buffer and timeouts inside http block:

http {
...
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
...
}

2) Ensure your php-fpm service is listening according to what you’ve configured in nginx, it can be either this two options:

Edit www.conf file (in CentOS it is located at /etc/php-fpm.d/www.conf and try with one of this two options:

listen = /var/run/php5-fpm.sock

or

listen = 127.0.0.1:9000

After that, just restart the php-fpm service.

3) Disable APC Cache if used, instead try Xcache, apc can cause this kind of issues under particular enviroments causing segmentation faults.

4)  I recently found another cause of 502 bad gateway error, check it out here: php5-fpm.sock failed (13: Permission denied) error


p.s
원인을 보면... 다양한데... 대부분 서버 부하입니다. 타임아웃 늘려주고 버퍼 늘려주고....
어느 정도 해결이 될 겁니다. 근데 곳곳에서 또 튀어 나오죠 ^^;
502 에러의 대부분은 아마 서버 부하로 인해 하드웨어적으로 램이 부족하여 일어나는 현상입니다.
그걸 요리조리 짜 맞추면서 분배를 잘 해야 하는데 쉽지 않습니다.

암튼 nginx 는 서버 부하 걸리면 곳곳에 숨어서 502 에러를 뿜어냅니다.
임시적으로 타임아웃 값과 버퍼를 늘려 기다리게 할 수는 있겠지만 근본적인 해결책은 아닙니다.
결론적으로 접속자가 많은 곳은 무조건 메모리를 빵빵하게 해라.. 그게 정답입니다..

참고로 최소 사양으로는 1G 이상 되는 곳에 nginx 를 사용하기를 권합니다.
그리고 저 위에 설정 문제들이라면 이것저것 만져보면서 해결이 되겠지만
간헐적이거나 서버 부하 문제라면 이 때는 무조건 램 증설이 답입니다. -.-;

 

| |





      5 page / 6 page
번 호 카테고리 제 목 이름 조회수
38 리눅스 서버 PHP 7.0 on CentOS/RHEL 6.7 and 7.1 via Yum 바다아이 19304
37 리눅스 서버 CentOS 7 firewalld iptables 바다아이 11794
36 리눅스 서버 , webalizer , 바다아이 11393
35 리눅스 서버 iptables ssh , ssh 바다아이 11172
34 리눅스 서버 ssh - fail2ban, SSH Brute-force attack 바다아이 14697
33 리눅스 서버 NGINX php ... 바다아이 60434
32 리눅스 서버 CentOS 7 | firewall-cmd 바다아이 11691
31 리눅스 서버 SSH (Secure Shell) 바다아이 14768
30 리눅스 서버 proftp , , proftpd.conf 바다아이 14401
29 리눅스 서버 centos 7 iptables firewall-cmd 바다아이 12661
28 리눅스 서버 바다아이 11696
27 리눅스 서버 netstat, nmap 바다아이 12099
26 리눅스 서버 Apache IP , 바다아이 11045
25 리눅스 서버 , 바다아이 11906
24 리눅스 서버 php php.ini , 바다아이 14509
23 리눅스 서버 mysql, mariadb (UTF8) .. ??? 바다아이 13444
22 리눅스 서버 , , , 바다아이 11989
21 리눅스 서버 top 바다아이 14666
20 리눅스 서버 [subversion] ubuntu subversion 바다아이 14321
19 리눅스 서버 2 mod_cband , 바다아이 15697
18 리눅스 서버 바다아이 11970
17 리눅스 서버 Apache event MPM, Prefork MPM, Worker MPM 바다아이 14926
16 리눅스 서버 Virtual Hosting 바다아이 14436
15 리눅스 서버 fedora selinux , ... , , ftp, mysql ... 바다아이 12560
14 리눅스 서버 ssh rsync 바다아이 11684
현재글 리눅스 서버 502 bad gateway using Nginx 바다아이 12125
12 리눅스 서버 nginx post .... 바다아이 10020
11 리눅스 서버 centos nginx php-fprm rpm 바다아이 11301
10 리눅스 서버 ssh ip or 바다아이 11409
9 리눅스 서버 nginx 405 바다아이 12276
| |









Copyright ⓒ 2001.12. bada-ie.com. All rights reserved.
이 사이트는 리눅스에서 firefox 기준으로 작성되었습니다. 기타 브라우저에서는 다르게 보일 수 있습니다.
[ Ubuntu + GoLang + PostgreSQL + Mariadb + PgBouncer + ProxySQL]
서버위치 : 오라클 클라우드 춘천  실행시간 : 0.04872
to webmaster... gogo sea. gogo sea.