title: nginx 403 forbidden error in Rails 4 (with no index.html file)
body: <p>I'm following along with a Railscast <a href="http://railscasts.com/episodes/293-nginx-unicorn?view=asciicast" rel="nofollow noreferrer">http://railscasts.com/episodes/293-nginx-unicorn?view=asciicast</a> about setting up Nginx and Unicorn on Vagrant, with one important difference. Ryan's making his application with Rails 3 (that has the default /public/index.html that Rails 4 only generates dynamically). After getting Nginx installed and running, we were able to see the default page on port 8080. We then created a basic config file for Nginx to put in the config directory of the rails application</p>
  
  <p><strong>/config/nginx.conf</strong></p>
  
  <pre><code>server {
   listen 80 default;
   # server_name example.com;
   root /vagrant/public; 
  }
  </code></pre>
  
  <p>and then removed the default page in sites enabled and symlinked to the configuration file</p>
  
  <pre><code>vagrant@lucid32:/etc/nginx/sites-enabled$ sudo rm default 
  vagrant@lucid32:/etc/nginx/sites-enabled$ sudo ln -s /vagrant/config/nginx.conf todo 
  </code></pre>
  
  <p>After this, Ryan restarted nginx and was able to see the Rails index page at localhost:8080. However, when I visit localhost:8080, I'm getting a 403 Forbidden error. </p>
  
  <pre><code>403 Forbidden
  nginx/1.1.19
  </code></pre>
  
  <p>Update</p>
  
  <p>since Rails 4 doesn't have the public/index.html file anymore, I think the 403 error might be caused by that, as I learned from this blog post 
  <a href="http://www.nginxtips.com/403-forbidden-nginx/" rel="nofollow noreferrer">http://www.nginxtips.com/403-forbidden-nginx/</a>. It says to set autoindex to <code>on</code> (the default is off) in the config, but I'm not sure how to set it to get the Rails homepage to show. </p>
  
  <p>When I did this</p>
  
  <pre><code>server {
   listen 80 default;
  
   root /vagrant/public; 
   location / {
                 autoindex on;
          }
  }
  </code></pre>
  
  <p>it got rid of the 403 permissions error (yay!), however, it's not showing the default Rails home page. Rather it's showing the directory structure so I'm wondering what the proper way to set it is. <img src="https://i.stack.imgur.com/OL9Mi.png" alt="enter image description here"></p>
  
  <p>If I try to set it to location/public, I get the 403 error again. Any ideas?</p>
  
  <pre><code>location /public {
                     autoindex on;
              }
  </code></pre>
  
  <p>Update</p>
  
  <p>Since I'm using Vagrant (virtual box), the app is in /vagrant, however setting the location to location/vagrant also results in a 403 error</p>
  
  <pre><code>location /vagrant {
                 autoindex on;
          }
  </code></pre>