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.

I wanted to find out what happens when Nginx is configured as a reverse proxy in front of Apache. Here is the scenario Nginx is set to handle .jpg files Apache is set handle .php files

There is a file.php which when requested also calls .jpg files.

What happens when the user requests file.php from this server, is request passed to Apache and then Apache picks up the connection and is communicating with the user directly or its sending processed info via Nginx and all communication goes via Nginx? Since .jpg is mentioned in .php file, will Apache serve .php and then Nginx pick up the .jpg serving?

If Nginx will serve .php processed by Apache then is this file saved/cached somewhere while Nginx is serving it?

Nginx is known to be prone to stuff like slowloris, will it ignore such a requests or will pass them to Apache when .php is requested?

There are some basic questions which are rarely answered anywhere.

share|improve this question

1 Answer 1

What happens when the user requests file.php from this server, is request passed to Apache and then Apache picks up the connection and is communicating with the user directly or its sending processed info via Nginx and all communication goes via Nginx?

Apache will only communicate with the nginx server, and the client will only communicate with nginx; as far as the Apache server knows (and as you'll see in its logs), the nginx proxy is the "client".

Since .jpg is mentioned in .php file, will Apache serve .php and then Nginx pick up the .jpg serving?

A request for a .jpg file will be a separate HTTP request, even though it may occur in the same connection; the nginx server will serve each individual resource as configured (.jpg locally, .php to Apache).

If Nginx will serve .php processed by Apache then is this file saved/cached somewhere while Nginx is serving it?

By default, no. proxy_cache configuration can change this; see the documentation.

Nginx is known to be prone to stuff like slowloris, will it ignore such a requests or will pass them to Apache when .php is requested?

It will pass them along to Apache, so a connection will be used on both servers; set a reasonably low-ish timeout on either the nginx or the Apache to mitigate.

share|improve this answer
    
So when slowloris like request comes in to Nginx, it will pass it to Apache and will not drop it instead? What if the php file processed by Apache is say 1MB in size and client to Nginx connection is only at 10KBs, will Nginx keep Apache's child process up for 100 seconds or it will take the request from Apache, cache it somewhere and then serve it to the client at 10KBs for 100 seconds? –  Namesniper Feb 27 '12 at 2:16
    
Slowloris actually works by never completely sending the request, sending tiny bits of it very slowly. There's no response to give (so, nothing to cache) when the request is never completed. Though, now that I give it some more thought, I'm not sure that nginx will ever make a connection to the backend Apache until the request is completely received from the client. –  Shane Madden Feb 27 '12 at 2:36
    
I am still unsure about it as well. –  Namesniper Apr 5 '12 at 22:14

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.