我的设置:
我想通过https访问控制器中的所有操作。所以我做了以下事情:
server { listen 443; ssl on; ssl_certificate /etc/ssl/cert.cer; ssl_certificate_key /etc/ssl/key.cer; root /path/to/public; 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 X-Forwarded-Proto https; 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; }
这些说明大部分来自:http://seaneshbaugh.com/posts/configuring-nginx-and-unicorn-for-force_ssl
现在,当我转到http://example.com/my_ssl_controller/action时,它会将我重定向到https://example.com/my_ssl_controller/action,然后呈现503"服务暂时不可用"错误。
感谢您的帮助!