![](/img/trans.png)
[英]Getting a 404 error when loading js file from an html file with inline <script>
[英]getting 404 error from nginx for a route which is redirecting to a .html file
我在 nodejs 中有以下路線
app.get('/admin', function (req, res) {
console.log("CAME HERE");
res.redirect('/login.html');
});
我的 nginx.conf 看起來像這樣
upstream dev{
server 127.0.0.1:3001;
}
server {
listen 80;
server_name dev.abc.com;
location /api {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_pass http://dev;
}
location /admin {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_pass http://dev;
}
}
現在,當我在瀏覽器dev.abc.com/admin
輸入這個 URL 時,頁面被重定向到http://dev.abc.com/login.html
但瀏覽器上顯示如下錯誤:
404 Not Found
nginx/1.0.5
本地主機一切正常。
我認為從 nginx 方面還有一些額外的事情要做,不確定是什么。
您當前的 Nginx 配置僅設置為為節點進程 @port 3001 提供服務,沒有提及任何靜態文件。
# replace with your public directory path
root /www/data;
location / {
try_files $uri $uri/ $uri.html =404;
}
參考: 提供靜態內容
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.