Nginx and Apache Any Advantages?
Wondering if I should do something like this or just use Nginx and the PHP-fpm that I have setup now and leave it. Advantages to either approach?
7 Replies
@mjruschak:
My only complaint might be that there is no easy way to let people add rewrite rules.
@mjruschak:
What I meant was. There is no easy way to let people add them in something like .htaccess files. Am I wrong? Creating the rewrite rules is not the issue for me.
No, nginx hasn't .htaccess-like files.
Why do you want let people to change .htaccess on your site?
Simply put. I just noticed that a lot of folks on here are running a reverse proxy and was wondering what the advantages if any of that would be. I don't see any but being a new Nginx user I am not totally aware of any (if any) disadvantageous.
I apologize. I could of communicated my question better in the original post which was vague.
@mjruschak:
Simply put. I just noticed that a lot of folks on here are running a reverse proxy and was wondering what the advantages if any of that would be. I don't see any but being a new Nginx user I am not totally aware of any (if any) disadvantageous.
Well, given an existing nginx/php configuration, I don't think there are any automatic advantages, sans something Apache can do that nginx can't. In terms of disadvantages, I suppose it's really just needing to support two server configurations and their integration, plus whatever additional resource running two servers takes up. So I wouldn't do it just for the heck of it, but there are certainly cases where it can make sense.
I think that typically people end up down this road by having used Apache first - often with mod_php rather than trying to set up a standalone php server - and then trying to further tune the resource it is using. So fronting it with nginx is an easy way to reduce load for static resources, while retaining their existing configuration with Apache handle the dynamic stuff.
When coming at it the other way (already having nginx and php working without Apache), there's less of an incentive to introduce Apache to the mix. However, I certainly wouldn't hesitate to do so if it had a feature that I particularly wanted. Whether that be .htaccess, better integration/support with an application stack you are using, or just some feature nginx can't quite match (e.g., cgi-bin), adding Apache behind nginx can in such cases be the best approach. But the need threshold is perhaps a little higher to add Apache to an existing nginx installation than vice versa.
Or to put it another way, let's say .htaccess support for users in their own private folders was a requirement (rather than a thought experiment) for your system for some reason. I wouldn't have any problems recommending the introduction of Apache and having nginx proxy requests for those portions of the site to it, rather than trying any workarounds to keep solely using nginx. And as with going the other direction, there's no real reason to disrupt your existing nginx/php setup by completely switching to Apache - just insert it into the mix for the stuff you need it for.
– David
Some apache modules, which don't have equivalents on nginx, are a primary reason for still using apache. modsecurity for exampley. I mostly still use it for modwsgi for my Django apps, which is really stable and gives me the performance I need.
Apache can be made reasonably lightweight by stripping out all the modules you don't need and running in mpm-worker model (instead of mpm-prefork). This means for PHP apps you need to move away from mod-php to something like mod-fcgid so as to avoid any PHP threading problems and to make apache processes lighter.