nginx容器前端文件目录必须为: /usr/share/nginx/html
html下面是各种文件:js,css,index.html 等。
其他报错:
js 找不到
解决:更改 vue 中,js 路径,使其符合实际情况
403
解决:index.html找不到,路径地址错了
nginx完整配置文件:
user www-data;
worker_processes 2;
worker_cpu_affinity 01 10;
pid /var/run/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
use epoll;
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 500m;
resolver 10.43.0.10;
log_format main '$time_local $remote_addr $remote_user $status '
'$request_time $request [$body_bytes_sent/$bytes_sent] '
'"$http_user_agent" "$http_referer" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name 127.0.0.1;
charset utf-8;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ =404;
}
}
server {
listen 8002;
server_name 127.0.0.1;
charset utf-8;
location / {
proxy_pass http://172.19.168.118:8000/;
}
}
}