Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Configure Nginx to serve .unityweb with gzip header

Discussion in 'WebGL' started by Abscissa256, Apr 1, 2018.

  1. Abscissa256

    Abscissa256

    Joined:
    Mar 12, 2018
    Posts:
    12
    This page shows how to configure IIS and Apache to serve the .unityweb file with the gzip header:

    https://docs.unity3d.com/Manual/webgl-deploying.html

    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.)
     
  2. fklingler-mitm

    fklingler-mitm

    Joined:
    Mar 7, 2017
    Posts:
    12
    You can add this location block in your server block:


     
    Jimbobob and Abscissa256 like this.
  3. Abscissa256

    Abscissa256

    Joined:
    Mar 12, 2018
    Posts:
    12
    Thanks, that worked.
     
  4. Jimbobob

    Jimbobob

    Joined:
    Sep 17, 2018
    Posts:
    1
    Thanks, this should really be added to the documentation!
     
    hayq_ and Kiori like this.
  5. eangulee

    eangulee

    Joined:
    Jun 30, 2014
    Posts:
    5
    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.
     
    twice7713 likes this.
  6. twice7713

    twice7713

    Joined:
    Apr 24, 2018
    Posts:
    21
    [
    Have you solved the problem?
    I have the same problem.
    404.png
     
    Last edited: Mar 10, 2020
  7. twice7713

    twice7713

    Joined:
    Apr 24, 2018
    Posts:
    21
    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!
     
  8. sabarife

    sabarife

    Joined:
    Apr 6, 2020
    Posts:
    2
    Sorry for my ignorance! What is the Root folder. What should I write there?
     
  9. twice7713

    twice7713

    Joined:
    Apr 24, 2018
    Posts:
    21
    1.function write to nginx.conf under server.

    2./YourRoot/RootFoloder is Your HTML folder.
     
  10. deplantec

    deplantec

    Joined:
    Jan 23, 2021
    Posts:
    1
    Just Perfect !! Thx
    !!
     
  11. Steven_Damian

    Steven_Damian

    Joined:
    Mar 1, 2021
    Posts:
    68
    So i got the same problem! Have a look! With apache2 and with nginx. I've tried both webservers. upload_2021-3-11_13-52-22.png
     

    Attached Files:

    • 22.png
      22.png
      File size:
      26.4 KB
      Views:
      10
unityunity