在Nginx上使用angular 4项目刷新页面时出错

时间:2017-10-05 12:47:35

标签: angular nginx

我正在尝试将我的角度4构建项目推向生产阶段。 当我刷新页面时,我有这个错误:

“404 Not Found”

这是我的nginx设置:

server {
  listen 80 default_server;
  # server_name 91.134.234.212;
  server_name localhost;
  root  /home/www/dropnet;
  error_page 404 /404.html;
  error_page 500 502 503 504 /500.html;

  location / {
    #try_files $uri$args $uri$args/ $uri/ /index.html = 404;
    try_files $uri $uri/ /index.html;
  }

  index index.html index.htm;
  # Here we proxy pass only the base path
  location /api {
    proxy_pass http://api_dropnet.neobe.com/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For 
    $proxy_add_x_forwarded_for;
  }

  # Here we proxy pass all the browsersync stuff including
  # all the websocket traffic
  location /browser-sync {
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_pass         /home/www/dropnet;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection "upgrade";
    proxy_set_header   Host $host;
  }
}

请问我做错了什么?

下面是webserver上的文件

index.html and app files

0 个答案:

没有答案