nginx with ssl: I get a 403 and log "directory index of '...dir...' is forbidden" log message. works fine with unencrypted connection

Posted by user72464 on Server Fault See other posts from Server Fault or by user72464
Published on 2012-11-08T15:29:36Z Indexed on 2012/11/08 23:04 UTC
Read the original article Hit count: 284

Filed under:
|
|
|
|

As mentioned in the title, I had nginx working fine with my rails app, until I tried to add the ssl server.

The unencrypted connection still works but the ssl always returns me a 403 page with the following line in the error log:

directory index of "/home/user/rails/" is forbidden, client: [my ip], server: _, request: "GET / HTTP/1.1", host: "[server ip]"

Below my nginx.conf server block:

server {
  listen 80;
  listen 443 ssl;

  ssl_certificate /etc/ssl/server.crt;
  ssl_certificate_key /etc/ssl/server.key;
  client_max_body_size 4G;
  keepalive_timeout 5;
  root /home/user/rails;
  try_files $uri/index.html $uri.html $uri @app;
  location @app {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://0.0.0.0:8080;
  }

  error_page 500 502 503 504 /500.html;
  location = /500.html {
    root /home/user/rails;
  }
}

the /home/user/rails directory and it's parent have all read to all rights. and they belong to the user nginx.

the certificate and key file have the following rights:

-rw-r--r-- 1 nginx root 830 Nov 8 09:09 server.crt -rw--w---- 1 nginx root 887 Nov 8 09:09 server.key

any clue?

© Server Fault or respective owner

Related posts about ruby-on-rails

Related posts about http