To run a SPA (single page application) like a normal angular or react app you need to configure your nginx.
Static files should be resolved normally like http://localhost:7000/favicon.ico or http://localhost:7001/main.94e6abcc6275689efbf2.js
All routes should be redirected (if no static file for this route was found) to the index.html of the SPA. Examples are routes like http://localhost:7000 or http://localhost:7000/start. The angular router is resolving the route internal!! Be careful if some static file won't be found, for example a image, the nginx config will return the index.html!!
-
the /content folder contains the SPA, in this example its a simple angular 7 application
-
the /conf folder contains the nginx configuration
Open cmd in the root level of the project:
-
Build the docker image
docker image build -t nginx-docker-spa .
-
Take a look at your local docker images
docker images
-
Create & start a container
docker container run -p 7000:80 nginx-docker-spa
-
You can run app in your browser via http://localhost:7000