Configure Nginx to serve .unityweb with gzip header

This page shows how to configure IIS and Apache to serve the .unityweb file with the gzip header:

But I use nginx as a server. How do I do it with Nginx? (And without Nginx trying to re-compress the already compressed files.)

You can add this location block in your server block:

2 Likes

Thanks, that worked.

Thanks, this should really be added to the documentation!

2 Likes

sorry,that did not work,i configed in nginx.conf
but then i got some errors,like this,

UnityLoader.js:4 GET http://localhost/uav/vs/Build/webgl.wasm.code.unityweb 404 (Not Found)
UnityLoader.js:4 [UnityCache] 'http://localhost/uav/vs/Build/webgl.wasm.code.unityweb' request failed with status: 404 Not Found
UnityLoader.js:4 GET http://localhost/uav/vs/Build/webgl.wasm.framework.unityweb 404 (Not Found)
UnityLoader.js:4 [UnityCache] 'http://localhost/uav/vs/Build/webgl.wasm.framework.unityweb' request failed with status: 404 Not Found
UnityLoader.js:4 GET http://localhost/uav/vs/Build/webgl.data.unityweb 404 (Not Found)
UnityLoader.js:4 [UnityCache] 'http://localhost/uav/vs/Build/webgl.data.unityweb' request failed with status: 404 Not Found
UnityLoader.js:3 Invoking error handler due to
Uncaught SyntaxError: Unexpected token <
blob:http://localhost/6a9dc159-e6c9-458d-94fc-a240069c0a5b:1 Uncaught SyntaxError: Unexpected token <
UnityLoader.js:3 Invoking error handler due to
Uncaught TypeError: UnityLoader[n] is not a function
UnityLoader.js:4 Uncaught TypeError: UnityLoader[n] is not a function
at UnityLoader.loadCode.Module (UnityLoader.js:4)
at HTMLScriptElement.o.onload (UnityLoader.js:4)

could someone give me a favor? I really appreciate it,thanks.

1 Like

[

Have you solved the problem?
I have the same problem.
5566405--574828--404.png

on my case

location ~ .+.unityweb$ {
root /YourRoot/RootFoloder; #this is very important if you have location root
add_header Content-Encoding gzip;
add_header Content-Type application/octet-stream;
}

resolve!

Sorry for my ignorance! What is the Root folder. What should I write there?

1.function write to nginx.conf under server.

2./YourRoot/RootFoloder is Your HTML folder.

Just Perfect !! Thx
!!

So i got the same problem! Have a look! With apache2 and with nginx. I’ve tried both webservers.6924077--812510--upload_2021-3-11_13-52-22.png

6891821--806021--22.png

Sorry for gravedigging everybody but in case of anyone stumbling across this, they added a documentation page about this issue:

2 Likes