nginx_apache rev proxy

MMarko

Verified User
Joined
May 10, 2006
Messages
75
Location
eu
Wanted to ask if someone could explain benefits of nginx_apache setup for static content.

From what I'm aware of, each static request goes via nginx proxy to apache which then returns static content back to nginx which then servers it to a client. I was thinking that in case static content is accessed nginx serves it directly, but after working on modifying headers noticed that nginx always returns headers set by apache for static content. Am I wrong here?
 
hi,

This is how it works:

php requests -> nginx -> apache (processed here by apache) -> nginx -> client.
static requests -> nginx -> apache -> nginx (processed here by Nginx) -> client

You may ask why dont: static requests -> nginx (processed here by Nginx) -> client, b/c we need .htaccess working correctly.
 
You are a little bit wrong there :) Nginx forwards requests for a file, and serves the file itself. If nginx would serve all the static content, none of .htaccess rewrite rules would work for js/css/image and other files. So, there would be no full compatibility. However, DirectAdmin provides an easy way to customize the templates, if you are sure that all of your websites don't use any URL rewrites for the static content, you can simply make nginx to serve the static files directly, whthout asking apache on where to find them on the disk. https://forum.directadmin.com/showthread.php?t=49438&page=3&p=256986#post256986
 
So for having full htaccess compatibility we have same number of nginx requests and apache requests, because apache is used to properly parse htaccess rules, and in fact we just added nginx layer? Meaning no real performance benefits from nginx? And basically nginx benefits show up if you rewrite virtual host templates to serve static content directly via nginx?
 
Last edited:
Hi,

We need apache only to parse php and do nothing more. So no rewrite, htaccess etc.
We want nginx to do all the intelligent rewrites and do the static content and sent php to apache.

Now I have the standard config from custombuild. And was suprised to see images-request in apache-logs. But indeed the nginx-config uses "location / {}" to do the proxy and nowhere I see: "location \.php${}"

In other posts here I learn that mod_aclr2 is used so you can use apache-configs. But what if you dont need them?
Is there any option in CB to tell that you dont want to set this kind of options in apache config?

Is there any info how to disable mod_aclr2 and additional stuff manual if there is no CB setting?

Greetz, Lydia
 
Sorry for my second reply.
But I am really a bit disappointed and frustrated about this :confused:

I really thought DA would set up the best efficient config. Now I learned, that DA tries to be 100% compatible.
I understand that that is needed. But why not better inform?
It took me hours of searching why I saw images in apache logs. And why there is no 'location \.php$' in the configs.
If I

I hope I have overlooked a setting in CB or that CB offer a new setting to give the user a choice: do you need config in apache or not.

Greetz, Lydia
 
Back
Top