Skip to content

Instantly share code, notes, and snippets.

@DJStompZone
Created July 24, 2025 06:09
Show Gist options
  • Save DJStompZone/ef864ce7ee4a0d728fdb05edd3e5934f to your computer and use it in GitHub Desktop.
Save DJStompZone/ef864ce7ee4a0d728fdb05edd3e5934f to your computer and use it in GitHub Desktop.
Sneaky Signature Flex

feat: Enable crossOriginIsolated mode for multithreaded WASM support

  • Uncommented COOP and COEP headers in main location block
  • Added Cross-Origin-Resource-Policy for .onnx and .wasm
  • Required for SharedArrayBuffer support and multithreading in onnxruntime-web

Related Issues

Fixes #34 Closes #34

Refs

Changes

 server {
     server_name unlimited.waifu2x.net;
     access_log /var/log/nginx/unlimited.waifu2x.net.access.log;
     root /home/nagadomi/nunif/waifu2x/unlimited_waifu2x/public_html;

     location ~ ^/(apple-touch-icon|browserconfig|mstile)(.*)\.(png|xml|ico)$ {
         return 204;
     }

     location / {
         add_header Cache-Control "public, max-age=3600, must-revalidate";

-        # If you want to enable multi-threading
-        #add_header Cross-Origin-Resource-Policy "cross-origin";
-        #add_header Cross-Origin-Embedder-Policy "require-corp";
-        #add_header Cross-Origin-Opener-Policy "same-origin";
+        # Enable crossOriginIsolated for WASM multithreading
+        add_header Cross-Origin-Resource-Policy "cross-origin";
+        add_header Cross-Origin-Embedder-Policy "require-corp";
+        add_header Cross-Origin-Opener-Policy "same-origin";
     }

     location ~* \.(onnx|pth)$ {
         add_header Cache-Control "public, max-age=86400, must-revalidate";
+        add_header Cross-Origin-Resource-Policy "cross-origin";
     }

     location ~* \.wasm$ {
         types {
             application/wasm wasm;
         }
+        add_header Cross-Origin-Resource-Policy "cross-origin";
     }

     listen 80;
 }

    Kind regards,
       DJ Stomp's profile picture DJ 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment