1

我正在使用 Ruby on Rails,使用 nginx 作为 Web 服务器,使用 unicorn 作为应用程序服务器。我尝试为我的应用程序配置 ssl,它的工作原理很完美。我使用的 nginx 配置如下所示。

upstream unicorn_domain {
  # This is the socket we configured in unicorn.rb
 server unix:/home/ubuntu/root_path/tmp/sockets/unicorn.sock fail_timeout=30;
 }
server {
      listen 80;
      server_name demo.domain.com;
      rewrite ^ https://demo.domain.com$request_uri? permanent;
      }
server {
    listen 443 ssl;
    client_max_body_size 4G;
    server_name demo.domain.com;
    ssl                   on;
    ssl_certificate       /etc/nginx/ssl/example.com_chain.pem;
    ssl_certificate_key   /etc/nginx/ssl/example.com.key;
    ssl_protocols         SSLv3 TLSv1;
    ssl_ciphers           ALL:-ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP;
    ssl_session_cache     shared:SSL:10m;


    keepalive_timeout 5;

    # Location of our static files
    root /home/ubuntu/root_path/public;
    access_log /home/ubuntu/root_path/log/nginx/nginx.access.log;
    location / {


        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        # If you don't find the filename in the static files
        # Then request it from the unicorn server
       if (!-f $request_filename) {
             proxy_pass https://unicorn_domain;
          break;
       }

      if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)\?[0-9]+$") {
        expires max;
        break;
     }

   }
}

但是我的应用程序的主页主要是使用 javascript 构建的,它有多个按钮,这些按钮通过单击操作弹出包含一些表单的 ajax 窗口。问题来了。当我们将 ssl 配置到站点时,窗口不会弹出。它只发生在主页中。在内部页面中,该功能正在运行。任何人都可以帮助我找出解决方案。

谢谢,问候

4

1 回答 1

0

Rails 4 ( http://edgeguides.rubyonrails.org/security.html#default-headers )

config/application.rb

config.action_dispatch.default_headers.merge!({
  'Access-Control-Allow-Origin' => '*',
  'Access-Control-Request-Method' => '*'
})
于 2015-01-21T07:31:35.157 回答