MAMP Pro 中的 HTTP2 支持

14

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

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


我建议使用Docker设置而不是MAMP。使用Docker,您将更加灵活。 - Matthias Kleine
你解决了吗?我也想知道。 - Niclas
4个回答

3

2
如Tarun所述,MAMP Pro中包含的Apache和Nginx版本不支持HTTP/2。此外,大多数浏览器需要现代版的OpenSSL(1.0.2)才能支持HTTP/2。
因此,您最好更改Apache和/或Nginx以支持它。然后,您可以复制适当的配置来连接到MAMP堆栈的其余部分(例如MySQL、PHP等)。
如果您使用Windows,则ApacheHausApache Lounge提供具有HTTP/2支持的最新Apache版本。或者,如果您喜欢Nginx,则可以直接从Nginx下载
如果您使用MacOS,则Homebrew允许您安装最新版本的Apache和Nginx。
或者,您可以使用Docker镜像(如果已设置),或者可以从源代码编译(对于MacOS而言相对简单,与Linux非常相似,但对于Windows来说则更加复杂)。

0

对于 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

可用语言:en

描述:支持HTTP/2传输层

状态:扩展

模块标识符:http2_module

源文件:mod_http2.c

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

MAMP Pro 4使用Apache 2.2.31未达到Apache的最小版本要求。

因此,您无法使用HTTP2模块。最好使用其他新版本的Apache通过docker或直接使用来处理HTTP2。


0
如果您正在使用Nginx,您可以将以下代码添加到您的服务器块或http块(全局)中的nginx.conf文件中。
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";

否则,如果您已经完成了Apache的设置,请打开Nginx设置并启用“将Nginx用作Apache的反向代理”。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接