title: Ghost Blog with Nginx getting Bad Gateway
body: <p>I'm getting the 502 bad gateway with my ghost application.
  I have researched all over the internet and I found no answers for this.</p>
  
  <p>My Ghost config.js:</p>
  
  <pre><code>var path = require('path'),
      config;
  
  config = {
      production: {
          url: 'http://supetar.italoborg.es',
          mail: {},
          database: {
              client: 'sqlite3',
              connection: {
                  filename: path.join(__dirname, '/content/data/ghost.db')
              },
              debug: false
          },
  
          server: {
              // Host to be passed to node's `net.Server#listen()`
              host: '127.0.0.1',
              // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
              port: '2368'
          }
      }
  }
  </code></pre>
  
  <p>My Nginx supetar.italoborg.es file:</p>
  
  <pre><code>server {
      listen 0.0.0.0:80;
  
      server_name supetar.italoborg.es;
      root /home/italo/www/supetar.italoborg.es/html;
      index index.html index.htm index.js;
      access_log /var/log/nginx/supetar.italoborg.es.log;
  
      location / {
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header HOST $http_host;
              proxy_set_header X-NginX-Proxy true;
  
              proxy_pass http://127.0.0.1:2368;
              proxy_redirect off;
  
              # Socket.IO Support
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
      }
  }
  </code></pre>
  
  <p>I created the symbolic link to folder sites-enabled:</p>
  
  <pre><code>lrwxrwxrwx 1 root root 47 Dec 16 12:10 supetar.italoborg.es -&gt; /etc/nginx/sites-available/supetar.italoborg.es
  </code></pre>
  
  <p>And I'm using PM2 to start the Ghost APP:</p>
  
  <pre><code>pm2 start index.js
  </code></pre>
  
  <p>When I try to start the Ghost APP using:</p>
  
  <pre><code>npm start
  </code></pre>
  
  <p>I can see the blog, but when I try with pm2, I'm getting bad gateway.</p>
  
  <p>I'm using:</p>
  
  <p>Ubunt 14.04 64bits</p>
  
  <p>Node v0.10.13</p>
  
  <p>Npm 2.1.12</p>
  
  <p>Thanks!</p>