Nginx and Apache Any Advantages?

As a noob to Nginx I must say I love it quite a bit. My only complaint might be that there is no easy way to let people add rewrite rules. This I can live with though. I have noticed some Linode users are running Nginx and Apache. Sounds like all the static content such as images and html pages are being loaded in Nginx and dynamic content on Apache 2.

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.

http://forum.linode.com/viewtopic.php?p=35445#35445

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.

@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?

I don't really. I can just see some people asking why they have to go through me to change the rewrite rules… This really isn't the issue though. Again I can live without that.

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

Exactly what I was looking for. Thank you!

I run both nginx and apache on a couple of linodes.

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.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct