Created
May 23, 2013 10:07
-
-
Save sentience/5635070 to your computer and use it in GitHub Desktop.
My nginx config for a unicorn-hosted Rails app. Hitting unicorn directly serves the application; however, attempting to load it via nginx produces a “directory index of … is forbidden” error as shown below. If I put an index.html file in the applicaiton’s `public` directory, nginx serves it fine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2013/05/23 08:12:15 [error] 19732#0: *1 directory index of "/var/www/leakcrawler/current/public/" is forbidden, client: 58.6.229.249, server: leakcrawler.example.com, request: "GET / HTTP/1.1", host: "leakcrawler.example.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream unicorn { | |
server unix:/tmp/unicorn.leakcrawler.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default deferred; | |
server_name leakcrawler.example.com; | |
root /var/www/leakcrawler/current/public; | |
location / { | |
gzip_static on; | |
} | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
try_files $uri/index.html $uri @unicorn; | |
location @unicorn { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://unicorn; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Success!!!
These lines were at fault:
Removing them fixed the problem.