title: Set up ghost blog on subdirectory of a laravel website with nginx
body: <p>I'm on Ubuntu 14.04 with nginx.
  My website is built with laravel and it works as you would expect: example.com, example.com/page, etc all works</p>
  
  <p>What I'm trying to do is the following:
  Every page on example.com should be served by laravel, except example.com/blog. the /blog should be served by Ghost.</p>
  
  <p>The location of the websites are:</p>
  
  <ul>
  <li>/var/www/laravel(/public) for the main site </li>
  <li>/var/www/ghost for the blog</li>
  </ul>
  
  <p>I managed to successfully install Ghost on a subdomain (ghost.example.com), thanks to the help of this tutorial: <a href="https://www.digitalocean.com/community/tutorials/how-to-create-a-blog-with-ghost-and-nginx-on-ubuntu-14-04" rel="nofollow">https://www.digitalocean.com/community/tutorials/how-to-create-a-blog-with-ghost-and-nginx-on-ubuntu-14-04</a></p>
  
  <p>Right now when I go to example.com/blog it links to example.com</p>
  
  <p>This is my nginx conf:</p>
  
  <pre><code>server {
      listen 443;
      ssl on;
      ssl_certificate ...;
      ssl_certificate_key ...;
  
      server_name example.com;
  
      include hhvm.conf;
  
      fastcgi_buffers 8 16k;
      fastcgi_buffer_size 32k;
      fastcgi_connect_timeout 300;
      fastcgi_send_timeout 300;
      fastcgi_read_timeout 300;
  
      root /var/www/laravel/public;
      index index.html index.htm index.php;
  
      location / {
  
         # URLs to attempt, including pretty ones.
         try_files   $uri $uri/ /index.php?$query_string;
  
      }
  
      location ^~ /blog {
          # this works perfectly
          # return 301 http://www.google.com;
  
          # I got this code from the tutorial
  
          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_set_header X-NginX-Proxy true;
  
          proxy_pass http://127.0.0.1:2368;
          proxy_redirect off;
  
     }
  
      # Remove trailing slash to please routing system.
      if (!-d $request_filename) {
              rewrite     ^/(.+)/$ /$1 permanent;
      }
  }
  </code></pre>
  
  <p>The ghost config file:</p>
  
  <pre><code> production: {
          url: 'https://example.com/blog',
          mail: {},
          database: {
              client: 'sqlite3',
              connection: {
                  filename: path.join(__dirname, '/content/data/ghost.db')
              },
              debug: false
          },
  
          server: {
              host: '0.0.0.0',
              port: '2368'
          }
      },
  </code></pre>