1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#This shows how to integrate a WP blog into a Rails site, as an Nginx config.
#I am leaving most of the RoR specific stuff out.

#You probably have an upstream for your mongrels already
upstream mongrel_NameOfSite {
 #Do not care what is in here.
}

upstream NameOfSite_blog {
  server blog.example.com:80;  #This server doesn't need to be publicly accessible.  Private IPs are fine, only Nginx will ever see it.
}

#Here we have your main server block.  We're going to intercept all requests made to URLs starting 
#with /blog/ and redirect them to the WP-using PHP server (Apache or whatever) rather than sending 
#them to Mongrel.
server {
    listen       80;

    server_name www.example.com;

    #Skipping a lot of your configuration
 
    location /blog {
      proxy_set_header  X-Real-IP  $remote_addr;
      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect false;

      gzip on;
      gzip_min_length  1100;
      gzip_buffers     4 8k;
      gzip_proxied any;
      gzip_types  text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
 
      if (!-f $request_filename) {
        rewrite ^/blog$     /;
        rewrite ^/blog/(.*)$ /$1;
        proxy_pass http://NameOfSite_blog;
        break;
      }
    }
    
    #You also have some proxy fun stuff for Rails, too.  That doesn't change.

    location / {
      #No changes here!
    }
}