Can someone enlighten me whats the advantage of having NginX as a reverse proxy to Apache. People suggest it so that static content is handled by nginx and dynamic content (php files) are handed over to Apache.
-
Wouldn't directly letting php-fcgi/php-fpm handle those PHP files a lot more reasonable than letting Apache's mod_php handle it?
-
What are the advantages (performance wise)
-
If I choose to reverse proxy, would I need to do a nginx rewrite or would the .htaccess from apache work as it is? (because its reverse proxied, so the calls are directed to apache right?)
TY in advance
Best Answer
Reverse proxying is slower and generally worse, however, some reasons to use it is to maintain (some) compatibility with .htaccess files (which you would have to write (and that isn't always practical) is you use a pure nginx setup) or if you require specific apache modules. (Some may argue that is you have these requirements, it is easier to just use apache.)
If you can, go with the straight nginx+PHP-FPM setup. If you can't, while there may be some merits to reverse-proxying, think through the repercussions, especially if you are dependent on .htaccess files.