如果一直報500 檢查:
靜態dist文件夾是否被nginx引用到,特別是docker部署進入容器看
root /code/dist;
server { listen 443 ssl; ssl_certificate /etc/nginx/cert/server.crt; ssl_certificate_key /etc/nginx/cert/server.key; server_name beta.sc.cn; charset utf-8; client_max_body_size 50M; location /api { include uwsgi_params; uwsgi_param HTTP_X_FORWARDED_PROTOCOL https; uwsgi_pass rookie:8000; } location / { root /code/dist; index index.html index.htm; try_files $uri $uri/ /index.html; } }
404 需要檢查nginx訪問文件權限問題,nginx.conf 一般第一行user root 用戶,實際訪問文件用戶組和用戶所有權限大小訪問問題:
nginx.conf
user root; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }
其他坑就是vue的了 路由使用mode:hash 和history nginx配置有點區別百度下