# Proxy - 2nd apache process started

**URL:** <https://www.ruby-forum.com/t/proxy-2nd-apache-process-started/164493>\
**Category:** NGINX\
**Created:** [April 1, 2009, 10:15pm UTC](https://www.ruby-forum.com/t/proxy-2nd-apache-process-started/164493 "2009-04-01T22:15:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [April 1, 2009, 10:15pm UTC](https://www.ruby-forum.com/t/proxy-2nd-apache-process-started/164493/1 "2009-04-01T22:15:40Z")

</div>

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?

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](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](http://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](http://11.22.33.44:8080);  
}

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [April 1, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/proxy-2nd-apache-process-started/164493/2 "2009-04-01T22:40:18Z")

</div>

On Wed, Apr 01, 2009 at 10:07:52PM +0200, removed\_email\_address@domain.invalid wrote:

> 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).

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [April 2, 2009, 12:00am UTC](https://www.ruby-forum.com/t/proxy-2nd-apache-process-started/164493/3 "2009-04-02T00:00:55Z")

</div>

Thanks a lot, this was the reason 😉  
Martin

* * *
