我只是尝试使用NodeJS和Nginx在我的码头容器上运行NodeJS,并从nginx错误日志中获得以下错误:
2021/06/05 07:34:28 [error] 13187#13187: *24 open() "/home/aguero/lasfar/website/admin/frontend/assets/global.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/global.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"
2021/06/05 07:34:28 [error] 13187#13187: *24 open() "/home/aguero/lasfar/website/admin/frontend/assets/app.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/app.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"
2021/06/05 07:34:28 [error] 13187#13187: *26 open() "/home/aguero/lasfar/website/admin/frontend/assets/design-system.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/design-system.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"
2021/06/05 07:34:28 [error] 13187#13187: *26 open() "/home/aguero/lasfar/website/admin/frontend/assets/components.bundle.js" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /admin/frontend/assets/components.bundle.js HTTP/1.1", host: "0.0.0.0:8080", referrer: "http://0.0.0.0:8080/admin"网页不显示任何错误,但为空白。
admin.js:
// ============================================
// Admin Bro
const AdminBro = require('admin-bro')
const AdminBroExpress = require('@admin-bro/express')
const adminBro = new AdminBro({
databases: [],
rootPath: '/admin',
})
adminBro.watch()
const router = AdminBroExpress.buildRouter(adminBro)
// ============================================
// Server
const express = require("express");
const server = express();
server
.use(adminBro.options.rootPath, router)
.listen(3000, () => console.log("Server started"));admin.js在/home/aguero/lasfar/网站/nodejs下面
nginx.conf:
user aguero;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server {
listen 0.0.0.0:80 default_server;
location /admin {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
sendfile on;
keepalive_timeout 65;
}nginx.conf文件上有更多的位置,但它们位于完全不同的路径上,因此为了简单起见,我删除了它们。
我用NodeJS脚本和APT安装了setup_16.x。这些软件包的安装有:
npm install tslib
npm i admin-bro @admin-bro/express express express-formidable我正在将端口80从容器映射到主机的8080端口。
知道为什么会出现这些错误吗?如果需要的话,我可以提供更多的信息。
发布于 2021-12-15 00:39:48
对我来说,proxy_pass中的ngnix.config中的这个正斜杠(/)导致了这个错误。假设您的快递应用程序在端口8000上运行,并且adminBro/adminJs可以在8000/admin中访问
location ^~ /admin/ {
proxy_pass http://localhost:8000/admin/;
}https://stackoverflow.com/questions/67847625
复制相似问题