Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Configuration Nginx到server node.js content+;静态内容_Configuration_Nginx - Fatal编程技术网

Configuration Nginx到server node.js content+;静态内容

Configuration Nginx到server node.js content+;静态内容,configuration,nginx,Configuration,Nginx,我有一个包含动态和静态内容的应用程序。我使用nginx作为这个应用程序的前端。当请求动态内容时,请求被转发到unix套接字(到node.js应用程序),这部分工作正常。我添加了一个“location”指令来提供静态内容,但这部分不起作用,尽管文件夹“/home/test/my_app/static”确实存在,但每次我都会收到404错误 这是我的nginx配置: upstream test_sock { server unix:/tmp/test.sock fail_timeout=0

我有一个包含动态和静态内容的应用程序。我使用nginx作为这个应用程序的前端。当请求动态内容时,请求被转发到unix套接字(到node.js应用程序),这部分工作正常。我添加了一个“location”指令来提供静态内容,但这部分不起作用,尽管文件夹“/home/test/my_app/static”确实存在,但每次我都会收到404错误

这是我的nginx配置:

upstream test_sock {
   server unix:/tmp/test.sock
   fail_timeout=0;
}

server {
   listen 15000;
   client_max_body_size 4G;
   server_name localhost domain.com;

   keepalive_timeout 5;

   location ~ /static/ {
      if (!-f $request_filename) {
         return 404;
      }
      if (-f $request_filename) {
         root    /home/test/my_app/static;
         expires 30d;
      }
   }

  location / {
     proxy_pass http://test_sock;
     proxy_redirect off;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header Host $http_host;
  }
}

有什么想法吗?

嗯。。。好吧,愚蠢的事情,我在位置指令之前错过了根指令