开发者

https not redirecting to mongrel upstream

Normal http is working fine for me with nginx and mongrel, however when i attempt to use https I am directed to the "welcome to nginx pa开发者_Go百科ge".

 http {
#    passenger_root /opt/passenger-2.2.11;
#    passenger_ruby /usr/bin/ruby1.8;

include       mime.types;
default_type  application/octet-stream;

#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';

#access_log  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

 upstream mongrel {
     server 00.000.000.000:8000;
     server 00.000.000.000:8001;
 }

   server {
    listen       443;
     server_name domain.com;


    ssl                  on;
    ssl_certificate      /etc/ssl/localcerts/domain_combined.crt;
    ssl_certificate_key  /etc/ssl/localcerts/www.domain.com.key;


   #    ssl_session_timeout  5m;

#    ssl_protocols  SSLv2 SSLv3 TLSv1;
#    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
#    ssl_prefer_server_ciphers   on;

    location / {
        root   /current/public/;
         index  index.html index.htm;

     proxy_set_header X_FORWARDED_PROTO https;
       proxy_set_header  X-Real-IP        $remote_addr;
  proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
  proxy_set_header  Host             $http_host;
  proxy_redirect    off;
  proxy_pass        http://mongrel;

    }
}

}


Do you have an explicit server entry for port 80? It could be that an nginx default directive is intercepting the regular HTTP traffic.

Add a another server block just to be sure:

server {
  listen 80; 
  server_name domain.com www.domain.com;

  rewrite ^(.*) https://domain.com$1 permanent;  
}

This will redirect all traffic for your app to https, which even if it isn't what you ultimately want to happen, at least you know you're missing the non-https block and you can then replace this with the directives you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜