Configuration Nginx到server node.js content+;静态内容
我有一个包含动态和静态内容的应用程序。我使用nginx作为这个应用程序的前端。当请求动态内容时,请求被转发到unix套接字(到node.js应用程序),这部分工作正常。我添加了一个“location”指令来提供静态内容,但这部分不起作用,尽管文件夹“/home/test/my_app/static”确实存在,但每次我都会收到404错误 这是我的nginx配置: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
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;
}
}
有什么想法吗?嗯。。。好吧,愚蠢的事情,我在位置指令之前错过了根指令