title: Nginx: Wordpress blog at non root context
body: <p>I've a site that runs in java and also have a wordpress blog(eg. www.example.com &amp; blog.example.com). I want to move blog to /blog context under my site so the url will look like www.example.com/blog.</p>
  
  <p>Since its a wordpress blog, I'm trying to use Ngix at port 80. I've moved java application at 8080 port and using reverse proxy to server java application at root context.</p>
  
  <pre><code>server {
      listen: 80;
      server_name: www.example.com;
  
      location / {
          proxy_pass http://internal-example-host:8080/; #resolved to localhost through /etc/hosts
      }
  
      location /blog {
          root /path/to/blog/root/folder;
          index index.php index.html;
  
          location ~ \.php$ {
              include fastcgi_params;
              fastcgi_pass unix:/var/run/php5-fpm-blog.sock;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              fastcgi_read_timeout 3600;
          }
      }
  }
  </code></pre>
  
  <p>To serve blog at /blog, I'm trying to configure location block under nginx server config by setting its own root directory. My java site works correctly. However for blog only homepage works and rest all pages gives 404 error. Logs shows that wordpress/nginx tries to server index.php for every request except home page and static resource.</p>
  
  <p>Can anybody help me out here?</p>
  
  <p>Thanks,
  Kiran.</p>