Welcome! Log In Create A New Profile

Advanced

Proxy to all backends

October 01, 2009 09:02PM
I have a rails app sitting behind nginx and every request is going to both of the mongrel instances. Pages are getting through. However, there are a few db intensive tasks that I don't want run two instances of. I've been playing with proxy_*_timeout and have turned proxy_next_upstream off and it still manages to duplicate each request. No errors are reported. A single access is recorded for a page as well as a single logging of a destination. Pages are returning with status of 304 and load balancer is dutifully alternating between the two. (When I shut one down I get 502-Bad Gateway errors on alternate requests.) I've included by conf file. I'm running 0.5.33. Any ideas would be appreciated.

Thanks in advance,
John

---------------------------------------------------------------------------
user www-data;
worker_processes 2;

pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

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

sendfile on;
tcp_nopush on;

keepalive_timeout 65;
tcp_nodelay off;

gzip on;

upstream myservers {
server 127.0.0.1:4010;
server 127.0.0.1:4011;
}

server {
listen 80;
root /var/www/qpd/public;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

rewrite_log on;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 5;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
proxy_next_upstream off;

log_format timing
'$remote_addr - $remote_user [$time_local] $request '
'upstream_response_time $upstream_response_time '
'msec $msec request_time $request_time sent to $upstream_addr $upstream_status';

access_log /var/log/nginx/proxy.log timing;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://myservers;
break;
}
}
}
}
Subject Author Posted

Proxy to all backends

jkolen October 01, 2009 09:02PM

Re: Proxy to all backends

Igor Sysoev October 02, 2009 02:44AM

Re: Proxy to all backends

jkolen October 02, 2009 02:12PM

Re: Proxy to all backends

jkolen October 02, 2009 05:47PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 201
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready