title: Nginx+Wordpress+Rails with wp as a subdirectory
body: <p>I have this environment almost working, but permalinks and images are not working.</p>
  
  <p>My site is deployed in /var/www/staging-site/current/public;
  My Wordpress blog is deployed in /var/deployer/www/blog;</p>
  
  <pre><code>http {
     server {
          listen  80;
          server_name www.mysite.com;
          access_log  logs/nosubdomain.access.log;
          return 301 $scheme://mysite.com$request_uri;
      }
  
      server {
          listen       80;
          server_name  mysite.com *.mysite.com;
          #charset koi8-r;
  
          access_log  logs/subdomain.access.log;
          root /var/www/staging-site/current/public;
  
  
          location / {
              passenger_enabled on;
              rails_env staging;
                  root /var/www/staging-site/current/public;
          }
  
          location /blog/ {
             root          /home/deployer/www;
             fastcgi_index  index.php;
  
             if (!-e $request_filename) {
               rewrite  ^(.*)$  /blog/index.php?q=$1  last;
             }
             fastcgi_param  SCRIPT_FILENAME    /home/deployer/www$fastcgi_script_name;
             fastcgi_pass   localhost:9000;  # port to FastCGI
             break;
          }
  
          location ~* ^/assets/{
                  root /var/www/staging-site/current/public;
                  expires max;
                  add_header Cache-Control public;
                  break;
          }
  }
  </code></pre>
  
  <p>I want www.mysite.com to show my site, and www.mysite.com/blog to show wordpress blog. It works, but the links doesnt work. For example <a href="http://mysite.com/blog/wp-content/uploads/2012/04/bname-268x300.jpg&amp;w=150&amp;h=150&amp;zc=1&amp;q=90" rel="nofollow">http://mysite.com/blog/wp-content/uploads/2012/04/bname-268x300.jpg&amp;w=150&amp;h=150&amp;zc=1&amp;q=90</a> doesnt show the image, that is there, it shows the root of the blog.</p>
  
  <p>Any help?</p>