Rails 3 with HTTPS and SSL is not working (only showing default page of nginx) -
configuring rails 3 nginx use https , ssl not working. shows nginx's default page(the page text --> welcome nginx!)
i have written config.force_ssl = true
in application.rb
my nginx's config file follows
# server { #listen 80; ## listen ipv4; line default , implied #listen [::]:80 default ipv6only=on; ## listen ipv6 # root /usr/share/nginx/www; # index index.html index.htm; # make site accessible http://localhost/ # server_name localhost; # location / { # first attempt serve request file, # directory, fall index.html # try_files $uri $uri/ /index.html; # uncomment enable naxsi on location # include /etc/nginx/naxsi.rules # } # location /doc/ { # alias /usr/share/doc/; # autoindex on; # allow 127.0.0.1; # deny all; # } # nginx-naxsi : process denied requests #location /requestdenied { # example, return error code #return 418; #} #error_page 404 /404.html; # redirect server error pages static page /50x.html # #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /usr/share/nginx/www; #} # pass php scripts fastcgi server listening on 127.0.0.1:9000 # #location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # note: should have "cgi.fix_pathinfo = 0;" in php.ini # # # php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; # fastcgi_index index.php; # include fastcgi_params; #} # deny access .htaccess files, if apache's document root # concurs nginx's 1 # #location ~ /\.ht { # deny all; #} #} # virtual host using mix of ip-, name-, , port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # root html; # index index.html index.htm; # # location / { # try_files $uri $uri/ /index.html; # } #} # https server server { listen 443; server_name localhost; root /usr/share/nginx/www; index index.html index.htm; ssl on; ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/server.key; ssl_session_timeout 5m; ssl_protocols sslv3 tlsv1; ssl_ciphers all:!adh:!export56:rc4+rsa:+high:+medium:+low:+sslv3:+exp; ssl_prefer_server_ciphers on; location / { try_files $uri $uri/ /index.html; } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } }
edit:
my site working fine before change(without https)
the steps followed were
add
config.force_ssl = true
in application.rbsudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/example
changed
/etc/nginx/sites-enabled/example
shown abovesudo ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/example
sudo service nginx restart
it's not ssl's fault. did not setup nginx correctly.
nginx proxy , must pass request rails app.
location / { proxy_set_header host $host; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header x-forwarded-proto https; proxy_redirect off; proxy_pass http://localhost:3000; }
Comments
Post a Comment