I've set up nginx to redirect certain URLs to https, this works fine. The SSL works when I get a 404, but not when I supply the correct root inside the location.

nginx.conf

server {
  listen 80;
  server_name example.com;
  root /var/www/apps/example.com/current/public;
  location / {
    passenger_enabled on;
    rails_env production;
  }
  location /admin {
    rewrite ^ https://example.com$request_uri? permanent;
  }

}

server {
  listen 443;
  server_name example.com;
  root /var/www/apps/example.com/current/public;
  passenger_enabled on;
  rails_env production;
  location / {
    rewrite ^ http://example.com$request_uri? permanent;
  }
  location /admin {
  }
  ssl on;
  ssl_certificate /opt/nginx/ssl/example_combined.crt;
  ssl_certificate_key /opt/nginx/ssl/example.key;
}

error.log

[error] 24503#0: *1 open() "/var/www/apps/example.com/current/public/admin" failed (2: No such file or directory), client: 12.107.20.18, server: example.com, request: "GET /admin HTTP/1.1", host: "example.com"

As you can see the location should just be /var/www/apps/example.com/current/public, but when I change the SSL location /admin to have root /var/www/apps/example.com/current/public; the page works but there is no SSL information.

http://pastie.org/private/etluwfpi7naykbzzcyolw

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.