$
Elad Damian Nachman
nachd1337gmail.com
# Docker web server configuration for Unity Web Players:
A simple guide for using Docker and Nginx to locally host and test Unity Web Players.
Github: https://github.com/eldnach/docker-nginx-unity
This sample modifies the Nginx server configuration file (`nginx.conf`), in order to serve Unity's (gzip/brotli) precompressed files and accelerate loading times:
## Instructions
1. Before starting, please verify that Docker is installed and running (https://docs.docker.com/get-docker/).
2. Create and navigate to a new project folder. Copy the contents of this repostiory to the root of your newly created project folder.
3. Rename the docker file (`project/docker/project-name.Dockerfile`) and edit the docker-compose file to match the new project's name (`project/docker-compose.yml`)
4. To reduce application loading times, ensure that Brotli/Gzip compression is enabled in your Unity project's Player Settings (`ProjectSettings -> Player -> Publishing Settings -> Compression Format`), and that "Decompression Fallback" is disabled:
5. This repository includes a sample Unity Player at the webplayer directory (`project-folder/webplayer`). To overrwrite the project, build a Unity Web Player and copy the build folder's contents to this directory.
6. Once the web player folder is ready, open a terminal at the project's root, and build a docker image using the following command: `docker build -t :local -f docker/.Dockerfile .`
7. Print and copy the docker image ID using the `docker images` command:
8. Run the docker container using the newly built docker image: `docker run -p 127.0.0.1:hport:cport imageid`.
Note: You can set both hport (host-port) and cport (container-port) to 80.
9. Once the docker container is running, open a web browser and navigate to `127.0.0.1:hport` in order to launch the web player:
Note: You can open the developer tools in order to verify that Unity pre-compressed files have been served with the correct `Content-Encoding` header (gzip/br):