title: Symfony nginx virtual host
body: <p>I have a virtual server with nginx, with my Symfony project installed in <code>/var/www/test</code>. In <code>/etc/nginx/site-avalible/test.conf</code> I create this config:</p>
  
  <pre><code>server {
  server_name test.dev www.test.dev;
  root /var/www/test/web;
  
  location / {
      # try to serve file directly, fallback to app.php
      try_files $uri /app.php$is_args$args;
  }
  
  location ~ ^/(app_dev|config)\.php(/|$) {
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_split_path_info ^(.+\.php)(/.*)$;
      include fastcgi_params;
  
      fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
      fastcgi_param DOCUMENT_ROOT $realpath_root;
  }
  
  location ~ ^/app\.php(/|$) {
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_split_path_info ^(.+\.php)(/.*)$;
      include fastcgi_params;
  
      fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
      fastcgi_param DOCUMENT_ROOT $realpath_root;
  
      internal;
  }
  
  location ~ \.php$ {
      return 404;
  }
  
  error_log /var/log/nginx/test_error.log;
  access_log /var/log/nginx/test_access.log;
  }
  </code></pre>
  
  <p>and then create symlink:</p>
  
  <pre><code>ln -s /etc/nginx/sites-available/test.conf /etc/nginx/sites-enabled/test.conf
  </code></pre>
  
  <p>and add rules to <code>/etc/hosts</code>:</p>
  
  <pre><code>127.0.0.1       test.dev
  </code></pre>
  
  <p>this is all done in the server. Then I know the IP of my virtual server and I create in my local computer in <code>/etc/hosts</code>:</p>
  
  <pre><code>82.91.183.61    test.dev
  </code></pre>
  
  <p>and then try to open in my browser but have a 502 error, why? And how can I correct the virtual host config for nginx and how do I open my project in my local computer if I know the IP and can create a virtual host?  </p>