【问题标题】:How to update a Ruby on Rails website form http 1 to http 2如何将 Ruby on Rails 网站从 http 1 更新为 http 2
【发布时间】:2019-03-25 16:05:33
【问题描述】:

目前使用 Rails 5.2 和 Ruby 2.3 与服务器:Nginx 与乘客

请说明将网站从 HTTP 版本 1 更新到 HTTP 2 所需的更改。

虚拟主机

 server {
    listen 80;
    listen [::]:80 ipv6only=on;

server_name ec2-34-xxx-xx-xx.us-west-2.compute.amazonaws.com;

# Tell Nginx and Passenger where your app's 'public' directory is
root /home/ec2-xxxx/apps/xxxxxxxxxx/public;

# Turn on Passenger
rails_env    production;
passenger_enabled on;
passenger_ruby /home/ec2-xxx/.rvm/gems/ruby-2.3.8@5.0.2/wrappers/ruby;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   html;
    }
location ~ /.well-known {
            allow all;
    }

}

提前致谢

【问题讨论】:

    标签: http nginx passenger http2 ruby-on-rails-5.2


    【解决方案1】:

    假设您使用的是相对较新的 Nginx 版本,您可以在 Nginx 配置中启用 HTTP/2。

    但是所有browsers only support HTTP/2 over HTTPS。由于您只监听 80 端口,我假设您只设置了 HTTP,所以您需要做的第一件事是在您的网站上设置 HTTPS。

    之后,您只需要以下配置(再次假设在最新版本的 Nginx 上),在端口 443 上使用协议http2 进行侦听:

    listen 443 ssl http2; 
    listen [::]:443 ssl http2 ipv6only=on;
    

    【讨论】:

      【解决方案2】:

      您需要将 Web 服务器配置为使用 HTTP/2,例如 tomcat / apache,并且客户端应用程序需要使用正确的使用 HTTP/2 的 httpclient / 适配器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-08
        • 1970-01-01
        • 1970-01-01
        • 2011-03-20
        相关资源
        最近更新 更多