0. 기본 폴더 : /home/docker/vuejs/front/

 

1. default.conf - 기본폴더/nginx/default.conf

vue.js router 사용하기 위한 설정

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

  root /usr/share/nginx/html;  

  index index.html;  

  server\_name vue-router.example.com;  

  location / {  
    try\_files $uri $uri/ @rewrites;  
  }  

  location @rewrites {  
    rewrite ^(.+)$ /index.html last;  
  }  

  location ~\* \\.(?:ico|css|js|gif|jpe?g|png)$ {  
    expires max;  
    add\_header Pragma public;  
    add\_header Cache-Control "public, must-revalidate, proxy-revalidate";  
  }  
}

 

2. vue.js build

dist 배포 디렉토리가 생성됨

npm run build

 

3. docker 실행

배포 디렉토리 및 nginx 설정파일을 nginx docker 와 연결

docker run --name vuejs_server -d -p 80:80 -v /home/docker/vuejs/front/dist:/usr/share/nginx/html -v /home/docker/vuejs/front/nginx:/etc/nginx/conf.d nginx

+ Recent posts