【问题标题】:HTTP2 support in MAMP ProMAMP Pro 中的 HTTP2 支持
【发布时间】:2017-03-30 22:05:32
【问题描述】:

有没有办法在 MAMP Pro 中启用 HTTP2 支持?我想测试和改进一些支持 HTTP2 的本地开发网站。

我已经搜索了一段时间,但没有找到一个解决方案。

【问题讨论】:

  • 我建议使用 docker 设置而不是 MAMP。使用 docker,您将更加灵活。
  • 你解决了吗?也想知道。

标签: apache nginx mamp http2 mamp-pro


【解决方案1】:

最近我用 NGINX 在 MAMP Pro 上为 NodeJS APP 配置了 HTTP2。我写了一篇关于它的短文https://www.linkedin.com/pulse/nodejs-http2-server-mamp-pro-nginx-sergei-iastrebov/我想它会对你有所帮助。

【讨论】:

    【解决方案2】:

    正如 Tarun 所说,MAMP pro 中包含的 Apache 和 Nginx 版本不支持 HTTP/2。此外,HTTP/2 需要现代版本的 OpenSSL (1.0.2) 才能在大多数浏览器上支持 HTTP/2。

    因此,您最好的选择是更改 Apache 和/或 Nginx 以支持此功能。然后,您可以复制适当的配置以连接到 MAMP 堆栈的其余部分(例如 MySQL、PHP..等)。

    如果您使用的是 Windows,那么 ApacheHausApache Lounge 提供支持 HTTP/2 的最新 Apache 版本。或者如果你更喜欢 Nginx,那么可以download these directly from Nginx

    如果您使用的是 MacOS,那么Homebrew 允许您安装最新版本的 Apache 和 Nginx。

    或者,如果为此设置了 Docker 映像,您也可以使用它,或者可以从源代码编译(MacOS 相对简单,与 linux 非常相似,但 Windows 稍微复杂一些)。

    【讨论】:

      【解决方案3】:

      如果您使用的是 Nginx,您只需将以下代码添加到您的服务器块或 http 块(用于全局)到 nginx.conf

      add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
      

      否则,如果Apache你可以做到以上,那么打开Nginx设置并启用“使用Nginx作为Apache的反向代理”

      【讨论】:

        【解决方案4】:

        适用于 MAMP Pro v4.0.0

        C:\>F:\MAMP\bin\nginx\nginx.exe -V
        nginx version: nginx/1.13.1
        built by cl 16.00.40219.01 for 80x86
        built with OpenSSL 1.0.1m 19 Mar 2015
        TLS SNI support enabled
        configure arguments: --with-cc=cl --builddir=objs --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe
        --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs/lib/pcre --with-zl
        ib=objs/lib/zlib --with-openssl=objs/lib/openssl --with-select_module --with-http_ssl_module --add-module=c:/MinGW/msys/1.0/home/Nebojsa/subsmodule/ngx_http_substitutions_filter_module
        

        Nginx 不是在 HTTP2 支持下构建的

        C:\>F:\MAMP\bin\apache\bin\httpd.exe -V
        Server version: Apache/2.2.31 (Win32)
        Server built:   May  6 2016 10:19:53
        Server's Module Magic Number: 20051115:40
        Server loaded:  APR 1.5.2, APR-Util 1.5.4
        Compiled using: APR 1.5.2, APR-Util 1.5.4
        Architecture:   32-bit
        Server MPM:     WinNT
          threaded:     yes (fixed thread count)
            forked:     no
        Server compiled with....
         -D APACHE_MPM_DIR="server/mpm/winnt"
         -D APR_HAS_SENDFILE
         -D APR_HAS_MMAP
         -D APR_HAS_OTHER_CHILD
         -D AP_HAVE_RELIABLE_PIPED_LOGS
         -D DYNAMIC_MODULE_LIMIT=128
         -D HTTPD_ROOT="/apache"
         -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
         -D DEFAULT_ERRORLOG="logs/error.log"
         -D AP_TYPES_CONFIG_FILE="conf/mime.types"
         -D SERVER_CONFIG_FILE="conf/httpd.conf"
        

        如果您查看 Apache HTTP2 模块

        Apache 模块 mod_http2

        可用语言:zh

        说明:支持 HTTP/2 传输层

        状态:扩展

        模块标识符:http2_module

        源文件:mod_http2.c

        兼容性:在 2.4.17 及更高版本中可用

        使用 Apache 2.2.31 的 MAMP Pro 4 不满足 Apache 的最低版本。

        所以你不能使用 HTTP2 模块。最好通过 docker 使用其他较新版本的 apache 或直接使用 HTTP2

        【讨论】:

          猜你喜欢
          • 2015-04-13
          • 2017-04-20
          • 2016-05-28
          • 2019-10-02
          • 2020-04-30
          • 1970-01-01
          • 1970-01-01
          • 2022-11-18
          • 1970-01-01
          相关资源
          最近更新 更多