1、首先拿到前端给的dist包,上传到服务器指定位置:/ajd/dist
2、找到nginx.conf配置文件,修改
server {
listen 9300;
server_name xxx.xx.xx.xx;
location / {
root /ajd/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/ {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'OPTIONS, GET, POST';
proxy_pass http://xxx.xx.xx.xx:9301/prod-api/;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
3、修改好后,执行
/usr/local/nginx/sbin/nginx -s reload
重载nginx
4、访问静态界面