我需要建议如何使用nginx实施以下规则:
如果用户请求domain.com(或任何域),请将其发送到node.js应用程序(proxy_pass http://localhost:8080;),但是如果用户直接请求任何文件或其他URL,则是清晰的顶级域名,Serve/img.png文件。
有什么想法如何实施?
您去这里:
if ($request_uri != "/") {
rewrite ^ /img.png last;
}
location /img.png {
internal;
root /path/to/image;
}
这是一种声明的方法:
location = / {
proxy_pass http://localhost:8080;
}
try_files /img.png =404;