在express.js中初始化应用程序时出错

时间:2016-11-09 10:23:22

标签: node.js express

我在包含 nodeJS 环境的服务器中使用 express.js 创建了 testApp 。网站正在 http://localhost:3000 中运行我已通过命令行检查输出 -

curl http://localhost:3000/

输出 -

<!DOCTYPE html>
<html>
 <head>
   <title>Express</title>
   <link rel="stylesheet" href="/stylesheets/style.css">
 </head>
 <body>
   <h1>Express</h1>
   <p>Welcome to Express</p>
 </body>
</html>

但我在我的域名中找不到它。它显示如下错误 -

Not Found
404

Error: Not Found

at /home/user/testApp/app.js:30:13
at Layer.handle [as handle_request] (/home/user/testApp/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/user/testApp/node_modules/express/lib/router/index.js:312:13)
at /home/user/testApp/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/home/user/testApp/node_modules/express/lib/router/index.js:330:12)
at next (/home/user/testApp/node_modules/express/lib/router/index.js:271:10)
at /home/user/testApp/node_modules/express/lib/router/index.js:618:15
at next (/home/user/testApp/node_modules/express/lib/router/index.js:256:14)
at Function.handle (/home/user/testApp/node_modules/express/lib/router/index.js:176:3)
at router (/home/user/testApp/node_modules/express/lib/router/index.js:46:12)

出现此类错误的可能原因是什么?

修改

应用结构:

.
app.js
bin
   www
package.json
public
    images
    javascripts
    stylesheets
        style.css 
routes
    index.js
    users.js
views
    error.jade
    index.jade
    layout.jade

Ngynx配置文件:

server {
    listen 80;

    server_name 10.10.10.15;

     location / {
            proxy_pass http://localhost:8080;
            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;
    }

    location /testApp {
            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;
    }
} 

0 个答案:

没有答案