[Solved] Vue project deploys nginx to refresh the interface 404 Error

1. Phenomenon

2. Solution

http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       8071;
        server_name  101.42.104.247;
        location/{
            root /home/intelligent_evaluation_of_rock_burst/development_project/dist;
            index index.html index.htm;
            try_files $uri $uri/ /index.html; //Add this line
        }
        #Dynamic requests
        location /api{
          include uwsgi_params;
          uwsgi_pass 127.0.0.1:5000;
        }

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

Nginx – s reload nginx

Nginx – t test whether nginx is normal

Read More: