使用以下指南HERE
将nginx设置为独角兽的负载均衡器nginx负载均衡器上的我的Vhost如下。
upstream unicorn_app {
server 192.111.111.111:8080 fail_timeout=0;
}
server {
server_name app.com www.app.com;
return 301 https://$server_name$request_uri;
}
# https SSL SPDY vhost
server {
listen 443 ssl spdy;
server_name app.com www.app.com;
ssl_certificate /usr/local/nginx/conf/ssl/app/app.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/app/app.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:AES128:AES256:RC4-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!kEDH:!EDH:!CAMELLIA;
ssl_prefer_server_ciphers on;
add_header Alternate-Protocol 443:npn-spdy/3;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
access_log /home/nginx/domains/app.com/log/access.log combined buffer=32k;
error_log /home/nginx/domains/app.com/log/error.log;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_app;
proxy_set_header X-Forwarded-Proto https;
}
}
该应用程序似乎正在运行并提供除css资产之外的请求。获得404。似乎Nginx没有将资产请求传递给Unicorn。