Results 1 to 12 of 12
  1. #1

    Nginx + cPanel/Apache


    We have a managed VPS (Virtuozzo + 512MB RAM) running cPanel+Apache+suphp and don't have any active site on it. Now we are planning to start an active image gallery on the VPS, so I am thinking of moving apache from port 80 and put Nginx in front but I am not sure about following things,

    - If we put Nginx in front and use Apache on back serving PHP, will we be getting the actual user details (ip etc.) in Apache/PHP or we will be getting the ip of the Nginx proxy?
    - I also want Nginx to serve the static contets/assets, but I think in this approach we will be serving images and other static contents with cookies as Nginx is listening for the main site and returning response from apache, so is there any way to send the assets using a cookie-free domain?
    - Is it possible for us to later add another VPS and use the same Nginx to load balance between the current VPS and new VPS?
    - Lastly, is it possible for Nginx to serve complete page or partial pages using a cache?

  2. #2
    Join Date
    Jan 2008
    nginx is basically configured to server static content - javascript, css, image files and it can cache a page, if it runs into a PHP page request it'll be redirected back to Apache to process the PHP file.

    Would take load off Apache for serving the static files and nginx can do this more efficiently.

    If you want real performance I'd suggest nginx+PHP-FPM setup which is atleast twice faster that classic Apache+PHP/nginx+Apache+PHP setups.

  3. #3

    the support of separate configs in nginx+PHP-FPM isn't good. we can load multiple configs in nginx, but any change in any config will require a nginx reboot.

    also my host don't provide full support of nginx, and also right now apache has far more community support compared with nginx.

    You are right about nginx for serving static contents, but I am more interested in knowing about cookies. When browser sends a request to web server, the header contains cookies, browser-related fields, requested URL and refferer URL.

    So I am interested in a way to use nginx to rewrite all the static content request to a special subdomain and serve the static contents using that sub-domain automatically.

  4. #4
    Quote Originally Posted by bryankewl View Post
    - If we put Nginx in front and use Apache on back serving PHP, will we be getting the actual user details (ip etc.) in Apache/PHP or we will be getting the ip of the Nginx proxy?
    install mod_rpaf to get the real IP, not the proxy

  5. #5
    Join Date
    Jan 2008

    Having your static files in a seperate subdomain will also have nginx to serve the static content from that location, however any PHP requests will be handed to PHP, cookies, sessions and everything related goes trough PHP, as it sets it, not Apache nor nginx.

    Also, I forgot to mention to use mod_rpaf module for Apache to get the real IP address of the visitor, so you stat logs will be more accurate

    Also, separate configurations loaded into nginx and PHP-FPM pools are running quite fine on several of mine servers and after fine tuning they're able to server a lot of requests at the same time.

  6. #6
    mod_rpaf's latest version is 0.6 and release in 2008 so are you sure this module or its support won't dump in future?

  7. #7
    Join Date
    Nov 2009
    Los Angeles,CA
    Mod rpaf is support apache in now.My server don't Use Cpanel But Use directadmin Nginx+Apache+PHP FCgi+Mem cache+Xcache It very fast. My apache is 2.2.18

  8. #8
    @rajapatr1 why are you using PHP as FCgi and I think memcache and xcache are work at same level, so is it possible to use both at same time?

  9. #9
    Join Date
    Nov 2009
    Los Angeles,CA
    I will test don't Fcgi my server was load 2-4 but i use fcgi it use Very low 0.6-1.5

  10. #10
    Join Date
    Sep 2010
    If you want a quick and easy way to deploy Nginx on cPanel check out

    i have used it on several boxes and it works well...It also integrates into WHM so you can stop, start and rebuild the vhost right from whm. It also does all the modification as far as modifying the ports needed to proxy back to apache.

  11. #11
    Join Date
    Feb 2008
    Houston, Texas, USA
    There's also the paid Nginx plugin for cPanel if you think you'll need support:

    Instead of rewriting URLs for static objects, I recommend moving all those objects to a subdomain and serving them from there.

    UNIXy - Fully Managed Servers and Clusters - Established in 2006
    [ cPanel Varnish Nginx Plugin ] - Enhance LiteSpeed and Apache Performance - Los Angeles | Houston | Atlanta | Rotterdam
    Love to help pro bono (time permitting). joe >

  12. #12
    the reason I want the rewriting instead of moving the actual files in a subdomain is
    - easy to install any applications and the rewriting will automatically convert the paths without any modification.
    - no need to create sub-domain manually

Similar Threads

  1. Replies: 0
    Last Post: 06-03-2011, 04:57 AM
  2. Nginx Admin: The Free cPanel Nginx automated installer Plugin
    By JohnCS in forum Software & Scripts Offers
    Replies: 13
    Last Post: 05-21-2011, 11:45 AM
  3. Using Nginx and Apache together
    By JitsuDan in forum Hosting Security and Technology
    Replies: 3
    Last Post: 05-03-2011, 05:49 PM
  4. Nginx cpanel pluginand apache settings
    By hostyourdream in forum Hosting Software and Control Panels
    Replies: 2
    Last Post: 01-09-2011, 06:35 PM
  5. Cpanel + Apache + Nginx proxy
    By dtredwell in forum Hosting Software and Control Panels
    Replies: 4
    Last Post: 06-05-2007, 04:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts