Welcome! Log In Create A New Profile

Advanced

nginx reverse proxy 502 bad gateway error

April 12, 2013 12:23PM
Hello,

I am getting 502 bad gateway error while trying to setup nginx server as reverse proxy server with caching enabled. Both servers are on seperate machines, another server having apache web server.

Given below are my config files, please help me.

nginx.conf
---------------------------------------------------------------------------------------------------------------------------------------
user www www;

worker_processes 1;

error_log /home/wwwlogs/nginx_error.log crit;

pid /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
{
use epoll;
worker_connections 51200;
}

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

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 32k;
fastcgi_buffers 8 16k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 256k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

#limit_zone crawler $binary_remote_addr 10m;

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


include vhost/*.conf;
}


---------------------------------------------------------------------------------------------------------------------------------------


www.example.com.conf
---------------------------------------------------------------------------------------------------------------------------------------
proxy_cache_path /usr/local/nginx/proxy levels=1:2 keys_zone=one:15m inactive=7d max_size=1000m;

server {
listen 80;
server_name www.example.com;
access_log off;
error_log off;
location / {
proxy_pass http://1.2.3.4:80;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache one;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
server
{ listen 80;
server_name example.com;
rewrite ^/(.*) http://www.example.com/$1 permanent;
}
---------------------------------------------------------------------------------------------------------------------------------------




Please note www.example.com is replaced with actual domain, and ip 1.2.3.4 is replaced with actual ip address in the original configuration file.

Additional Information :

I have done the lnmp installation using the script available here : http://www.ruchirablog.com/lnmp-v08-complete-nginx-auto-installer/
Subject Author Posted

nginx reverse proxy 502 bad gateway error

cruise April 12, 2013 12:23PM

Re: nginx reverse proxy 502 bad gateway error

Maxim Dounin April 12, 2013 12:36PM

Re: nginx reverse proxy 502 bad gateway error

cruise April 12, 2013 01:12PM

Re: nginx reverse proxy 502 bad gateway error

cruise April 12, 2013 03:11PM

Re: nginx reverse proxy 502 bad gateway error

gatha May 20, 2016 01:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 155
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready