我是 nginx 的新手,我无法访问我的公共文件,请指导我,我是新手。
这是我在 express js 上的代码
app.use('/p',auth, express.static('public/uploads'),
serveIndex('public/uploads', {'icons': true}))
这是nginx上的代码
location =/file/{
proxy_pass http://localhost:8081/p/;
}
当我转到 http://mywebsite.com/file/ 时,它在我的页面上确实像这样工作,但是当我们单击此处显示该目录的文件时。它会出错或保持白屏
here is the full code of the location
#this is the file system
location =/file/{
proxy_pass http://localhost:8081/p/;
}
#this is the express api
location /v1
{
rewrite ^/v1/(.*)?$ /$1 break;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8081;
}
#this is the front end
location /
{
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:5000;
}