DDEV不';t在Nginx中处理SVGZ文件

DDEV不';t在Nginx中处理SVGZ文件,nginx,svg,ddev,Nginx,Svg,Ddev,我在Typo3 v9环境中使用DDEV v1.15.3。我根据快速指南用ddev config--project type=Typo3--PHPVersion7.3--docroot=public--create docroot=true创建了Typo3环境。到目前为止,一切正常,但没有显示SVGZ文件 上传到fileadmin后端的svgz文件不会显示在类似浏览器的页面中。我收到以下错误消息: 此页面包含以下错误: 第1列第1行出错:编码错误 下面是第一个错误之前的页面呈现。 为了在nginx

我在Typo3 v9环境中使用DDEV v1.15.3。我根据快速指南用ddev config--project type=Typo3--PHPVersion7.3--docroot=public--create docroot=true创建了Typo3环境。到目前为止,一切正常,但没有显示SVGZ文件

上传到fileadmin后端的svgz文件不会显示在类似浏览器的页面中。我收到以下错误消息:

此页面包含以下错误: 第1列第1行出错:编码错误 下面是第一个错误之前的页面呈现。

为了在nginx容器中启用gzip压缩,我在文件.ddev/nginx\u full/nginx site.conf中添加了以下行

# Compression
gzip on;
gzip_proxied        any;
gzip_comp_level     6; # Level of compression
gzip_http_version   1.1;
gzip_min_length     1100;
gzip_buffers        16 8k;

gzip_types
 text/plain
 text/css
 text/xml
 application/x-javascript
 application/atom+xml
 text/mathml
 text/vnd.sun.j2me.app-descriptor
 text/vnd.wap.wml
 text/x-component
 text/javascript
 application/javascript
 application/json
 application/xml
 application/rss+xml
 font/truetype
 font/opentype
 application/vnd.ms-fontobject
 image/svg+xml svg svgz;

gzip_static on;
gunzip on;
gzip_proxied        expired no-cache no-store private auth;
gzip_disable        "MSIE [1-6] \."; # Disable for IE < 6

# Add a vary header for downstream proxies to avoid sending
# cached gzipped files to IE6
gzip_vary on;

# ### Compression ###

# For CSS with compression
location ~* "\.css(\.|\.\d{10}\.)gzip$" {
        rewrite ^(.+css)\.(\d+\.)gzip$ /$1.gzip;
        add_header  Content-Encoding gzip;
        add_header  Vary Accept-Encoding;
        add_header Access-Control-Allow-Origin *;
        gzip off;
        types { text/css gzip; }
        expires max;
        log_not_found off;
}

# For JavaScript with compression
location ~* "\.js(\.|\.\d{10}\.)gzip$" {
        rewrite ^(.+js)\.(\d+\.)gzip$ /$1.gzip;
        add_header  Content-Encoding gzip;
        add_header  Vary Accept-Encoding;
        gzip off;
        default_type application/javascript;
        expires max;
        log_not_found off;
}

# Compression for SVGZ
location ~* \.svgz$ {
       add_header Content-Encoding gzip;
}

压缩 gzip on; gzip_代理任何; gzip_comp_第6级;#压缩程度 gzip_http_版本1.1; gzip_最小长度1100; gzip_缓冲器168k; gzip_类型 文本/纯文本 文本/css 文本/xml application/x-javascript application/atom+xml text/mathml text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml 文本/x组件 文本/javascript 应用程序/javascript 应用程序/json 应用程序/xml application/rss+xml 字体/truetype 字体/开放式 应用程序/vnd.ms-fontobject image/svg+xml-svg-svgz; gzip_静态开启; 加油; gzip_代理过期无缓存无存储私有身份验证; gzip#u禁用“MSIE[1-6]\.;#禁用IE<6 #为下游代理添加vary标头以避免发送 #缓存的gzip文件到IE6 gzip_随时间而变化; #####压缩### #用于压缩CSS 位置~*“\.css(\.\.\d{10}\.)gzip$”{ 重写^(.+css)\.(\d+\.)gzip$/$1.gzip; 添加标题内容编码gzip; 添加_头,改变接受编码; 添加_头访问控制允许原点*; gzip关闭; 类型{text/css gzip;} 最大值; 未发现注销日志; } #用于带压缩的JavaScript 位置~*“\.js(\.\.\d{10}\.)gzip$”{ 重写^(.+js)\.(\d+\.)gzip$/$1.gzip; 添加标题内容编码gzip; 添加_头,改变接受编码; gzip关闭; 默认_类型应用程序/javascript; 最大值; 未发现注销日志; } #SVGZ的压缩 位置~*\.svgz${ 添加标题内容编码gzip; } 当我使用ddev ssh连接到docker容器时,nginx配置也包含上述行

谢谢你的帮助

致意


--Gerald

您需要在.ddev/nginx_full/nginx-site.conf中添加什么

location ~ \.svgz$ { add_header Content-Encoding gzip; }
我把我的nginx-site.conf文件放在

我使用了来自

解释了该怎么做

下面是我在1)使用文件管理器上载example.svgz,然后2)单击“显示”图标后看到的内容


如果您认为这对添加到默认nginx配置很重要,请在

打开一个问题或PR,我最初完全没有抓住要点,但现在添加了一个很好的答案。