Skip to content

示例工程本地预览没问题,部署到Nginx,按照文档配置,停留在初始页面转圈? #1206

Closed
@ZYMain

Description

@ZYMain

如题
https://github.com/vueComponent/ant-design-vue-pro.git
直接clone到本地的工程
npm install
npm run serve (本地预览正常)
npm run build (打包正常)

打包后的dist文件夹上传到服务器,按文档配置了nginx配置,始终首页转圈圈,报错
image

image

nginx配置我贴出来,求帮助,网上说什么给vueConfig里添加publicPath: './',把history改成hash,还有说什么非根目录,我都尝试了,还是一样的问题

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include 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  logs/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;

server {
    listen       80;
    
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";

   root /dist;

   location / {
   	  try_files $uri $uri/ /index.html;
   }

   location /api {
	  proxy_set_header   X-Forwarded-Proto $scheme;
       proxy_set_header   Host              $http_host;
       proxy_set_header   X-Real-IP         $remote_addr;
       proxy_pass   https://preview.pro.antdv.com; 
   }

   error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions