NginX proxying Nodejs/Express - 404 on static files

后端 未结 1 1060
北恋
北恋 2021-01-22 05:42

I have a setup with NginX which serves a php website off the root from /var/www and proxies Nodejs/Express on a particular subdirectory on my server. Here is the relevant config

相关标签:
1条回答
  • 2021-01-22 06:29

    If you want to access the static files through a different route, pass the route as the first argument :

    You can use app.use('/static', express.static(__dirname + '/public'));

    and a GET to http://server/static/css/main.css will serve main.css

    Also if you want to serve static files through nginx this article is a good start: USING NGINX TO AVOID NODE.JS LOAD

    0 讨论(0)
提交回复
热议问题