Welcome! Log In Create A New Profile

Advanced

Re: Proxy - 2nd apache process started

April 01, 2009 04:25PM
On Wed, Apr 01, 2009 at 10:07:52PM +0200, mates007@centrum.cz wrote:

> Hello nginx users!
>
> I an running nginx/0.6.32 on Debian Lenny as a proxy server for Apache.
>
> I have a script sleep.php which does nothing but sleeps for 120 seconds and then displays phpinfo.
>
> When I call sleep.php bypassing nginx proxy, I can see output after 120 seconds. This is expected.
>
> When I call sleep.php througt proxy, weird things happens:
> Apache process is in status Sending Reply for 90 seconds.
> In 90th second, another apache process is started, executing sleep.php
> In 120th second, 1st process finishes
> In 150th second 504 Gateway Time-out is sent to browser
> In 210th second, 2nd process finishes
>
> Is there any explanation for this weird behaviour?
> Why 2nd process is started?

After 90s (proxy_read_timeout 90) nginx closes connection to the proxied
server issues 504 error. Since there is

error_page 502 503 504 /50x.html;

nginx redirects internally the error to /50x.html. However, you have
no static location for /50x.html and the request is passed to Apache again:

location / {
proxy_pass http://11.22.33.44:8080;

This is why another Apache process is started. After the second 90s
timeout (i.e., after 180s) nginx shows default 504 page (since
recursive_error_pages is off).


> Thanks,
> Martin
>
>
>
> My nginx configuration:
>
> nginx.conf:
> ----------
>
> user www-data www-data;
> worker_processes 1;
>
> events {
> worker_connections 1024;
> use epoll;
> }
>
> http {
> root /var/www/nginx-default/;
> index index.html;
> error_page 502 503 504 /50x.html;
> error_log /var/log/nginx/error_log;
>
> server_names_hash_max_size 2048;
> #server_names_hash_bucket_size 128;
>
> include /etc/nginx/mime.types;
> default_type application/octet-stream;
>
> sendfile on;
> tcp_nopush on;
> tcp_nodelay on;
>
> keepalive_timeout 10;
>
> log_format main
> '$remote_addr - $remote_user [$time_local] '
> '"$request" $status $bytes_sent '
> '"$http_referer" "$http_user_agent" '
> '"$gzip_ratio"';
>
> #gzipping all text content
> gzip on;
> gzip_min_length 1100;
> gzip_buffers 4 32k;
> gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
> ignore_invalid_headers on;
>
> client_header_timeout 3m;
> client_body_timeout 3m;
> send_timeout 3m;
> connection_pool_size 256;
> client_header_buffer_size 4k;
> large_client_header_buffers 4 32k;
> request_pool_size 4k;
> output_buffers 4 32k;
> postpone_output 1460;
>
>
> server {
> listen 11.22.33.44:80;
>
> location /nginx_status {
> stub_status on;
> allow 99.88.77.66;
> deny all;
> }
>
> location /server-status {
> proxy_pass http://11.22.33.44:8080/server-status;
> }
>
> #default proxy settings for each virtual host
> include /etc/nginx/proxy.conf;
>
> }
>
> #add fine-tuned virtual hosts
> include /etc/nginx/sites-enabled/*.conf; #see below
> }
>
>
> proxy.conf:
> -----------
> location / {
> client_max_body_size 10m;
> client_body_buffer_size 128k;
>
> proxy_send_timeout 90;
> proxy_read_timeout 90;
>
> proxy_buffer_size 4k;
> proxy_buffers 16 32k;
> proxy_busy_buffers_size 64k;
> proxy_temp_file_write_size 64k;
>
> proxy_connect_timeout 30s;
>
> proxy_pass http://11.22.33.44:8080;
> 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;
> }
>
>
>
> One of the sites:
> -----------------
>
> server {
> listen 11.22.33.44:80;
> server_name www.example.com;
>
> include /etc/nginx/proxy.conf;
>
> location ~* ^.+.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|html?|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3)$ {
> #forcing browser to cache locally static content for 30 days
> expires 30d;
> root /home/apache/example.com/www/htdocs;
>
> #graceful fallback in case if static content doesn't exist
> include /etc/nginx/proxy_fallback.conf; #see below
> }
> }
>
>
> proxy_fallback.conf:
> --------------------
> proxy_set_header Host $host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> if (!-f $request_filename) {
> break;
> proxy_pass http://11.22.33.44:8080;
> }
>
>

--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Proxy - 2nd apache process started

mates007@centrum.cz April 01, 2009 04:07PM

Re: Proxy - 2nd apache process started

Igor Sysoev April 01, 2009 04:25PM

Re: Proxy - 2nd apache process started

mates007@centrum.cz April 01, 2009 05:45PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
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