title: Nginx redirect from http to https is stuck
body: <p>I'm deploying a Rails application on personal server using Nginx, phusion_passenger. I've site configuration file with following server blocks. With this configuration my <a href="https://192.168.1.121" rel="nofollow">https://192.168.1.121</a> service works but my connection doesn't redirect from <a href="http://192.168.1.121" rel="nofollow">http://192.168.1.121</a>. What am I doing wrong? I really appreciate any help, please.</p>
  
  <pre><code>server {
          listen 80 default_server;
          listen [::]:80 default_server ipv6only=on;
  
          # Make site accessible from http://localhost/
          #server_name 192.168.1.121;
          server_name mydomain.com www.mydomain.com
  
          return 301 https://$server_name$request_uri;
  }
  
  server {
          # Make site accessible from http://localhost/
          listen 443 ssl default;
  
          #server_name 192.168.1.121;
          server_name mydomain.com www.mydomain.com
  
          # Certificate details
          ssl_certificate     /etc/nginx/ssl/nginx.crt;
          ssl_certificate_key /etc/nginx/ssl/nginx.key;
          ssl_session_timeout 5m;
  
          ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
          ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
          ssl_prefer_server_ciphers on;
  
          passenger_enabled on;
          rails_env production;
  
          root /home/deploy/www/myapplication/current/public;
          index index.html index.htm;
  
          error_page 500 502 503 504 /50x.html;
          location = /50x.html {
                  root html;
          }
  }
  </code></pre>