Deploy and config NGINX on Angular 7 + Nginx Docker


  1. Create and run docker image
    1. docker run --name app-nginx -p 9595:80 -v /media/storage/angular7nginx-app/:/usr/share/nginx/html:ro -d nginx
  2. Go to docker image
    1. docker exec -ti app-nginx /bin/bash
  3. vim /etc/nginx/nginx.conf
  4. Add these line of code inside the http
  5. Restart docker container
  6. Check docker logs
    1. docker logs app-nginx
      1. app-nginx is application name

server {
    listen 80;
    listen [::]:80;

    server_name http://ip;

    root /usr/share/nginx/html;

    index index.html index.htm;

    location / {
        try_files $uri $uri/ /index.html;
# This will allow you to refresh page in your angular app. Which will not give error 404.
    }
}



usefull commands on docker:

  • docker commit app-nginx nginx:latest  --> create a new docker with latest tag
  • docker logs app-nginx -f                       --> tail docker log with -f option
  • docker ps -a                                           --> see running dockers in details
  • docker rm app-nginx                             -->  remove app-nginx docker image

Bu blogdaki popüler yayınlar

About Android padding, margin, width, height, wrap_content, match_parent, R Class

@SerializedName and @Expose annotations