Skip to content

byteleaf/nginx-docker-spa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nginx docker image for a SPA (Single page application)

Introduction

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!!

Explanation

  • the /content folder contains the SPA, in this example its a simple angular 7 application

  • the /conf folder contains the nginx configuration

How to run with docker

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

About

How to create a nginx docker image for a angular, react or vue single page application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published