Good day. I tried hosting my unity webgl protoype game on some free hosting sites but I’ve encountered some problems, enough for me to consider using a paid hosting service instead. With this, I’m looking at Amazon Web Services. Has anyone tried hosting a WebGL build in AWS? If yes, how was setup process and performance of the build? Do you have any better recommendations over AWS? My apologies that I’m asking several questions in one post. I’m trying to be specific as possible. Thanks in advance.
It might be worth looking at basic shared VPS hosting, it will probably work out cheaper than AWS. The cheapest ones won’t handle a lot of traffic but should be OK for testing and development.
Basically though, anything that lets you install your own server software should not present any problems. The places you’ll have trouble with are the ones who run specific server software on shared hosting and don’t give individual clients access to the config files.
Real WebGl Hosting: https://cpanel.hostinger.ru/. Without problem create http://www.myunity5.zz.mu/. Sorry for my English
Our game is hosted on Amazon S3 (part of AWS) without any issues.
The only thing is that it doesn’t work with the .htaccess file, so we have to rename a few files and set their content type to gzip.
Thanks for your inputs. Just to add, part of the issues that I encountered are:
- Upload timeout in FTP for large files (I tried 70 MB which I think is still fairly small). I used FireZilla and SmartFTP but both of them resulted to an error, so when I tested the build by accessing the actual external URL of the html page, the javascript threw an error since the file was not completely transferred. I’ve already searched for guides and forum posts and based on what I’ve read so far, it’s either the server or the router that I’m using. I think it’s the former…
- When I uploaded the file successfully (at least that’s what I think it is when FireFTP returned a success message after upload with no errors), the javascript error still occurs. My hunch is that the server needs to be refreshed for the updated file contents. Is my hypothesis correct?
Will I still encounter the same problems when I use AWS, VPS, or other paid hosting services?
@Andrejus I was actually using hostinger in the Philippine domain, but I can’t successfully upload the 70 MB file due t timeout when I used the mentioned FTP clients. Is there a configuration that I need to adjust? I can’t find such setting in the cPanel. Thanks.
@liortal I see, so it will still has some tweaking to do. That’s what I’m trying to avoid given that I’m not that much acquainted with server setups, but if the service is that reliable, then I’m willing to tinker. Thanks!
I don’t know what is the solution on that, but I know that some servers needs to be recoded (probably by adding some html file or sorta) in order to accept and stream webgl games. Good luck
@liortal , can you elaborate on what changes you make to enable hosting on s3?
The only thing we did was to enable compression support. S3 does not use the .htaccess file, so we had to manually do the steps that this file does:
- Rename Compressed folder → Release
- Rename all *.*gz files to drop the gz extension, eg: blabla.datagz renamed to blabla.data
- Mark all file as content-encoding: gzip after uploading to S3.
That’s very helpful - thank you!
@liortal
Followed all the steps except the last one.
Could not make out how to set the content encoding.
Please refer the image attached. I modified the metadata property and added content-encoding. Is it correct ?
I could not get the game running with this setting
Yes thats how we do it (maybe we dont set the first property though)
As @liortal said, we renamed by killing the gz because during the async download process its looking for the .mem file and if its memgz it bails out.
Hello everyone – I would like to help out this thread by sharing what worked for me to deploy WebGL through AWS S3. You cannot do this by simply copying folders over if you want to deliver /Compressed/ content, because .htaccess handles rerouting the requests for /Release/ to /Compressed/, and S3 does not allow .htaccess. Here is what I did that works.
Deploy /compressed/ webgl build to S3
- Build WebGL project from Unity
- Delete /Release/ folder
- Remove gz from the end of each filename in /Compressed/ folder
- Rename /Compressed/ to /Release/ folder.
- Upload your entire /WebGLgame/ folder to S3. Make sure you set permission to publicly accessible.
- Modify the headers of each file in /Release/ by adding “Content-Encoding”:“gzip” through the S3 console.
voila, you should be able to navigate to s3bucket.aws.com/WebGLgame/index.html and play your game using the compressed files.
Hi! is it able to do such things with WebGL in Unity5.3.2?
We tried:
- Build WebGL project from Unity
- Remove gz from the end of each filename in /Release/ folder
- Remove gz from the end of each url in index.html
- Remove .htaccess file
- Upload the entire folder to S3, make public.
- Modify the content encoding files (appname.js,mem,data) which is originally jsgz, memjz, datajz to application/x-gzip.
But we have a “SyntaxError: illegal character” error.
We need help, thanks!
Hello nbalexis1.
Did you try all those steps separately or in combination?
5.3.x builds should normally work without any modifications (you might need to remove the .htaccess on some hostings though). It might however not work properly after some modifications to the server configuration have been made. Could you undo all the server configuration changes, upload the original build to the server and provide the link? (here or privately)
We finally make it work!
It turns out that we are confusing about Content-Type and Content-Encoding.
Hi! We make it work though I have not yet check without modifications. Thank you all the same. We just set Content-Type to octet-stream/javascript and set Content-Encoding to Gzip
Hello nbalexis1,
I have tried Content-Type → “octet-stream/javascript” & Content-Encoding → “gzip”
Made the entire folder public.
Still doesnt work.
I use Unity 5.3.x to create the WebGL build
Can you share the full setup details of WebGL on Amazon S3…
CheeseGames.net is a free hosting site for WebGL Unity games.
Give it a try.
Just FYI, I followed nbalexis’s instructions successfully using a build from Unity 5.3.4 with no issues.
-
Build WebGL project from Unity
-
Remove gz from the end of each filename in /Release/ folder
-
Remove gz from the end of each url in index.html
note: I did not have to do this step, my index.html did not specify any ‘gz’ files. -
Remove .htaccess file
-
Upload the entire folder to S3, make public.
-
Modify the content encoding files (appname.js,mem,data) which is originally jsgz, memjz, datajz to application/x-gzip.
(this means add the header ‘content-encoding: gzip’ to the 3 files up on S3, I did this with the free Cloudberry Explorer application) -
everything works just fine! I don’t see any more gzip decompression delays when loading the game of of S3.