NGINX - performance HTTP server Support Forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Unofficial (YET) support forums for NGINX, a performance HTTP server.

Pages: [1]   Go Down

Author Topic: Using Nginx, SSI and Memcache to Make Your Web Applications Faster  (Read 853 times)

0 Members and 1 Guest are viewing this topic.

katmai

  • Administrator
  • Jr. Member
  • *****
  • Karma: 0
  • Offline Offline
  • Posts: 57
    • View Profile
code]# Defining mongrel cluster
    upstream mongrel {
        server 127.0.0.1:8150;
        server 127.0.0.1:8151;
        server 127.0.0.1:8152;
        server 127.0.0.1:8153;
    }

    # Defining web server
    server {
        listen 216.86.155.55:80;
        server_name domain.tld;

        # All dynamic requests will go here
        location / {
            default_type text/html;
           
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;
           
            # All POST requests go to mongrel directly
            if ($request_method = POST) {
                proxy_pass http://mongrel;
                break;
            }
           
            # Say nginx to try to fetch some key from memcache: "yourproject:Action:$uri", like ""yourproject:Action:/posts/1"
            set $memcached_key "yourproject:Action:$uri";
            memcached_pass localhost:11211;

            proxy_intercept_errors  on;
           
            # If no info would be found in memcache or memecache would be dead, go to /fallback location
            error_page 404 502 = /fallback$uri;
        }

        # This location would be called only if main location failed to serve request
        location /fallback/ {
            # This means, that we can't get to this location from outside - only by internal redirect
            internal;
           
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;           
            proxy_redirect off;

            # Pass request to mongrel
            proxy_pass http://mongrel/;
        }

        # Some static location to serve directly w/o bothering backend
        # (here should be more of such static paths or one regex-based location)
        location /images/ {
            root /rails/lazygeeks/public/current/public;
        }
    }[/code]

Notice: This config is not optimal, but it shows us what we’re going to do here.

So, what do can we see above: ng
Code: [Select]
     # This location would be called only from SSI tags
              location /dynamic {
                  # This means, that we can't get to this location from outside - only by internal redirect
                  internal;
                 
                  proxy_set_header Host $http_host;
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;           
                  proxy_redirect off;

                  # Pass request to mongrel
                  proxy_pass http://mongrel;
              }
   4. Replace dynamic parts in your templates with
      <!--# include virtual="full_url_to_your_partial" -->

      where full_url_to_your_partial is something like http://domain.tld/dynamic/login_field. Code: [Select]
     # This location would be called only from SSI tags
              location /dynamic {
                  # This means, that we can't get to this location from outside - only by internal redirect
                  internal;
                 
                  proxy_set_header Host $http_host;
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;           
                  proxy_redirect off;

                  # Pass request to mongrel
                  proxy_pass http://mongrel;
              }
   4. Replace dynamic parts in your templates with
      <!--# include virtual="full_url_to_your_partial" -->

      where full_url_to_your_partial is something like http://domain.tld/dynamic/login_field.
Logged

zlzqq

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 16
  • Just started
    • View Profile
Re: Using Nginx, SSI and Memcache to Make Your Web Applications Faster
« Reply #1 on: August 05, 2010, 07:29:38 AM »


Based in the Greater wow power leveling Toronto Area, Global Translation and Writing Services offers professional translation services wow power leveling for over 60 languages. We provide two-way translation from English to wow power leveling Chinese, Spanish, Farsi, Arabic, German, Italian, Korean . . . and many other aion kina languages. We translate business contracts, company brochures, websites, marketing buy wow gold copy, information notices, technical manuals, scripts, multimedia presentations, and other materials. We specialize gold in wow in website localization, marketing translation, legal translation and technical translation. We wow gold eu also provide legal document translation with certification, notarization and certified wow gold cheap true copy services. We offer layout and formatting services, and can make sure cheap aion power leveling that your translated documents in different languages are consistent EVE ISK in their presentation.
Logged
Pages: [1]   Go Up
 

Page created in 0.04 seconds with 20 queries.