【发布时间】:2022-01-31 18:05:18
【问题描述】:
系统已在 elasticbeanstalk 中启动并运行,此处在 .ebextensions 文件夹中添加了配置(位于文件夹根目录中)
nginx-proxy.config
option_settings:
aws:elasticbeanstalk:environment:proxy:
GzipCompression: 'true'
ProxyServer: nginx
gzip.config
files:
/etc/nginx/conf.d/gzip.conf:
content: |
gzip on;
gzip_types application/json application/xml text/html text/xml text/plain application/javascript text/css;
gzip_vary on;
也试过tomcat-settings.config,但结果是一样的
option_settings:
aws:elasticbeanstalk:environment:proxy:
GzipCompression: 'true'
ProxyServer: nginx
目前仅获取这些响应标头
cache-control →no-cache, no-store, max-age=0, must-revalidate
content-type →application/json
date →Mon, 31 Jan 2022 08:31:22 GMT
expires →0
pragma →no-cache
server →nginx/1.20.0
strict-transport-security →max-age=31536000 ; includeSubDomains
vary →Origin, Access-Control-Request-Method, Access-Control-Request-Headers
x-content-type-options →nosniff
x-frame-options →DENY
x-xss-protection →1; mode=block
应用程序属性文件
server.compression.enabled=true
server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,application/javascript,text/css
也尝试为邮递员添加此标头
'accept-encoding: gzip'
【问题讨论】:
-
在您的请求中,您是否发送
Accept-Encoding标头?也许那是缺失的,这就是服务器没有使用 gzip 压缩响应的原因。 -
是的,已添加到应用程序属性文件中。问题已更新
标签: amazon-web-services nginx tomcat amazon-elastic-beanstalk gzip