angular2 universal和nginx不能正常工作

时间:2016-09-29 12:54:14

标签: nginx angular

我在使用nginx服务angular2 universal时遇到了问题。

我的应用程序的根目录我在下面运行:

npm run build准备可分发的捆绑包 npm start构建您的客户端应用并启动Web服务器

这是我的nginx:

server {

     listen 80 default_server;
     listen [::]:80 default_server;
     root /var/greenlabel-starter/src;

     # Add index.php to the list if you are using PHP
     index index.html index.htm index.php index.nginx-debian.html;

     #server_name example.net;

     location / {
         # First attempt to serve request as file, then
         # as directory, then fall back to displaying a 404.
         try_files $uri $uri/ =404;
     }

     # Here we proxy pass only the base path
     location = / {
         proxy_set_header   X-Real-IP $remote_addr;
         proxy_set_header   Host      $http_host;
         proxy_pass         http://127.0.0.1:3000;
     }

         # Here we proxy pass all the browsersync stuff including
         # all the websocket traffic
    location /test {
         proxy_set_header   X-Real-IP $remote_addr;
         proxy_pass         http://127.0.0.1:3000;
         proxy_http_version 1.1;
         proxy_set_header   Upgrade $http_upgrade;
         proxy_set_header   Connection "upgrade";
         proxy_set_header   Host $host;
     }
 }

问题是:

http://test.com:8051/index.js 404

是index.html

 <script src="/index.js"></script>

文件位于dist / server / index.js

如何查找文件,以免出错?

0 个答案:

没有答案