无法在runcloud nginx服务器上解决wasm / unityweb错误

sf6xfgos  于 2023-01-12  发布在  Nginx
关注(0)|答案(1)|浏览(303)

网站托管在Ubuntu 18服务器上,由runcloud.ioPHP 7.4 runcloud的nginx默认配置管理。
我们在临时服务器上部署了一个webgl构建版本,但无法在不引发控制台错误的情况下加载它:
You can reduce your startup time if you configure your web server to host .unityweb files using gzip compression.
wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.
falling back to ArrayBuffer instantiation
我已经创建了以下nginx配置文件:

location ~ .(wasm)$ {
    add_header Content-Encoding gzip;
    add_header Content-Type application/wasm;
}

location ~ .(unityweb)$ {
    add_header Content-Encoding gzip;
    add_header Content-Type application/octet-stream;
}

location ~ .(data.unityweb)$ {
    add_header Content-Encoding gzip;
    add_header Content-Type application/octet-stream;
}

location ~ .(wasm.framework.unityweb)$ {
    add_header Content-Encoding gzip;
    add_header Content-Type application/octet-stream;
}

include /etc/nginx-rc/mime.types;
types {
    application/wasm wasm;
}
default_type application/octet-stream;
    
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types application/wasm application/octet-stream text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;
jw5wzhpr

jw5wzhpr1#

我设法在nginx服务器上托管Unity/WelGL应用程序,更改我的Unity“项目设置”的参数:
在“播放器”选项卡中,打开“发布设置”:

  • 压缩格式:格齐普
  • 减压回退:开启

已在Unity WebGL documentation上找到解决方案。这可避免错误消息。
我没有改变我的nginx配置文件。

相关问题