Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I try to view my website homepage I get the following error dislayed: 502 Bad Gateway Nginx

The error log found at /var/log/nginx shows the message: *2014/04/21 10:30:39 [error] 3807#0: 228 upstream sent invalid header while reading response header from upstream, client: 95.136.96.5, server: agronegocios.eu, request: "GET / HTTP/1.1", upstream: (MyIPaddress):7080/", host: "agronegocios.eu"

My environment: CentOS 6.5; PHP 5.3.3; nginx/1.5.0; MySQL 5.1.73; Joomla 3.2.3 Anyone know how can I get rid of this problem? I´ve seen some related questions and answers but none is to the same problem...(and also I'm not an expert on linux servers...). Thanks.

My nginx.conf file:

#user  nginx;
worker_processes  1;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;


events {
  worker_connections  1024;
}


http {
  include       mime.types;
  default_type  application/octet-stream;

  #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  #                  '$status $body_bytes_sent "$http_referer" '
  #                  '"$http_user_agent" "$http_x_forwarded_for"';

  #access_log  /var/log/nginx/access.log  main;

  sendfile        on;
  #tcp_nopush     on;

  #keepalive_timeout  0;
  keepalive_timeout  65;
  #tcp_nodelay        on;

  #gzip  on;
  #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

fastcgi_buffers 8 16k;
  fastcgi_buffer_size 32k;
  server_tokens off;

  include /etc/nginx/conf.d/*.conf;
}
share|improve this question
    
Could you show us your nginx config? –  algui91 Apr 21 at 11:05
    
Look at the php/fastcgi log, it's typically an error in the upstream service –  LinuxDevOps Apr 22 at 18:51

2 Answers 2

I detected where (yet not what) was causing the error: a template module in the CMS extensions that is not working properly. Disabling the module made the error go away. Anyway, thanks for your opinions and efforts!

share|improve this answer

I was an administrator for a McAfee Web Gateway product in another job that I had. While not Nginx, it's a RHEL proxy server operating on standard HTTP response codes.

Whenever I received a Bad Gateway error, it's always been an upstream device causing the issue. The error, as I understand, means that the proxy received a response from the upstream device that it didn't like. My environment had many "homegrown" apps, and it was typically found that the app was not properly communicating per the RFCs. Other times we found it was issues with unparsable headers that we needed to create a policy to exempt those sites from deep header inspection. I'm going to try to remember what headers it was tripping over, and I'll repost back here when I find out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.