部署前端到oss上,既方便通过oss的sdk发布版本,又大大提高访问速度,减少服务器带宽压力
nginx.conf 配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| worker_processes 1;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65;
server { listen 80; server_name localhost;
location /deploy/path { try_files $uri @redirect; }
location @redirect { rewrite ^ /oss/path/index.html break; proxy_pass http://your-bucket.oss-cn-shenzhen-internal.aliyuncs.com; } } }
|
运行服务
使用docker运行
1
| docker run --restart always --name your-app-name -v `pwd`/nginx.conf:/etc/nginx/nginx.conf:ro -dp 3000:80 nginx
|