Bundled scene fails to load from nginx HTTP server

I bundle the scene from client and unzip it to nginx root path. Config the file as ‘.nginx-location.conf’ do.But I can’t load the scene in web sit .The informations I can provide bellow:
web error:


web console info:

Nginx config:

Is there anything wrong?

Hi!

The main issue is that the location directive takes a HTTP path of the resource, not the local path. It is the root directive which specifies where the resources are locally, and in your case it would be best to move it to the outer scope, to make it common for all the location directives.

Please try:

    server {
        listen       8090;
        server_name  localhost;

        root E:/LearnForever/Threejs/threejs_git/webgldo/;

        location ~ ^/exampleroom/index\.html$ {
            add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
        }

        location ~ ^/exampleroom/cover\.json$ {
            # cover.json is precompressed in the bundle.
            gzip off;
            add_header Content-Encoding gzip;
            add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
        }

        location ~ ^/exampleroom(/.*\.(bmp|buf|js|json|ktx|svg|ico))$ {
            # Disable gziping for these extensions, because such files are
            # precompressed in the bundle.
            gzip off;
            add_header Content-Encoding gzip;
        }
    }

Then, your scene should be accessible as http://localhost:8090/exampleroom.

I tried. Here is the report:

  1. When I use config like this , it is 404 error:
    server {
    listen 8090;
    server_name localhost;

     root E:/LearnForever/Threejs/threejs_git/webgldo/;
    
     location ~ ^/exampleroom/index\.html$ {
         add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
     }
    
     location ~ ^/exampleroom/cover\.json$ {
         # cover.json is precompressed in the bundle.
         gzip off;
         add_header Content-Encoding gzip;
         add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
     }
    
     location ~ ^/exampleroom(/.*\.(bmp|buf|js|json|ktx|svg|ico))$ {
         # Disable gziping for these extensions, because such files are
         # precompressed in the bundle.
         gzip off;
         add_header Content-Encoding gzip;
     }
    

    }

  2. When I make the config like this , it is still 'walk not defind ’ error
    server {
    listen 8090;
    server_name localhost;

     root E:/LearnForever/Threejs/threejs_git/webgldo/;
    
     location ~ ^exampleroom/index\.html$ {
         add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
     }
    
     location ~ ^exampleroom/cover\.json$ {
         # cover.json is precompressed in the bundle.
         gzip off;
         add_header Content-Encoding gzip;
         add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
     }
    
     location ~ ^exampleroom(/.*\.(bmp|buf|js|json|ktx|svg|ico))$ {
         # Disable gziping for these extensions, because such files are
         # precompressed in the bundle.
         gzip off;
         add_header Content-Encoding gzip;
     }
    

    }

I am quite helpless…

Are you accessing the scene as http://localhost:8090/webgldo/exampleroom or http://localhost:8090/exampleroom?

Could you disable browser cache in the Network tab of the Developer Tools? And then could you try to access: http://localhost:8090/exampleroom with the first of the above nginx configs once again?

I tried to disable browser cache and use the first nginx config .But it is still 404 error.Perhaps I have a wrong RegExp . I will try again and would you continue to help me?

I soved the problem . Although it is not clear why. The new configtion like this:

location / {
root F:/shapespark/;
index index.html index.htm;
if ($request_uri ~ ^./index.html$){
add_header Cache-Control “no-store, no-cache, must-revalidate, max-age=0”;
}
if ($request_uri ~ ^.
.json$){
add_header Content-Encoding gzip;
add_header Cache-Control “no-store, no-cache, must-revalidate, max-age=0”;
}
if ($request_uri ~ ^.*.(bmp|buf|js|json|ktx|svg|ico)$){
gzip off;
add_header Content-Encoding gzip;
}
client_max_body_size 1000m;
}

I will determine the specific reason after this period of time.

Thanks for the update.

Not working location directives looks like some mismatch between HTTP path and regexp or local path. If you are still trying to make the location directives work, could you please write where the bundled scene is currently on your hard drive (F:/shapespark/?), what the name of the scene directory is (exampleroom? without a dash between example and room?), and what what URL you are using to access the scene?

My bundled scene on the hard drive ‘F:/shapespark/’ and the scene directory is ‘exampleroom’ . The URL is ‘http://localhost:8800/exampleroom/index.html’.
Is that right?

Yes, that’s right except that the port in your previous examples was 8090 not 8800, but I guess it may just be a typo in your post?

I’ve just tries to reproduce your setup, and the nginx configuration based on location directives should work for this case as well:

server {

  listen 8090;
  server_name localhost;

  root F:/shapespark/;

  location ~ ^/exampleroom/index\.html$ {
    add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
  }

  location ~ ^/exampleroom/cover\.json$ {
    # cover.json is precompressed in the bundle.
    gzip off;
    add_header Content-Encoding gzip;
    add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
  }

  location ~ ^/exampleroom(/.*\.(bmp|buf|js|json|ktx|svg|ico))$ {
    # Disable gziping for these extensions, because such files are
    # precompressed in the bundle.
    gzip off;
    add_header Content-Encoding gzip;
  }
}

You mean the RegExps need config at the root of the ‘server’?
I will try later.
By the way , I change the port at this config to 8800~

Yes , you are right. It seems the first location make the others error .
Thank you for your help.

The location directives can also have root directives inside, but I’ve placed root directive in the outer level (server), because they would be the same.

Hello I have encountered the same error. “walk is not defined” my current http is http://localhost/showroom/index.html

Walk is not giving me an error when i put it in the window.onload = function() { }
but anywhere outside that throws error

Could you check if the Network tab of the Chrome developer tools shows any error that indicate some failed requests?