Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';作为代理运行node.js时,请不要运行route_Javascript_Node.js_Nginx_Proxy - Fatal编程技术网

Javascript Can';作为代理运行node.js时,请不要运行route

Javascript Can';作为代理运行node.js时,请不要运行route,javascript,node.js,nginx,proxy,Javascript,Node.js,Nginx,Proxy,我使用nginx作为服务器,node.js作为代理(listen:3000),有一个名为user的路由,代码如下 exports.index = function (req, res){ res.render('user', { id: req.params.id }); }; 如果我跑。。。它工作得很好,但如果我跑步。。。它显示错误“404”,并且运行良好,那么如何修复它呢 nginx配置: listen 80; server_name domai

我使用nginx作为服务器,node.js作为代理(listen:3000),有一个名为user的路由,代码如下

exports.index = function (req, res){
  res.render('user', {
        id: req.params.id
    });
};
如果我跑。。。它工作得很好,但如果我跑步。。。它显示错误“404”,并且运行良好,那么如何修复它呢

nginx配置:

    listen 80;
    server_name domain.com www.domain.com;
    index index.html index.htm index.php;

    # Make site accessible from http://localhost/
    if ($host = 'www.domain.com' ) {
            rewrite ^/(.*)$  http://domain.com/$1   permanent;
    }


    location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://127.0.0.1:3000/;
            proxy_redirect off;
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ =404;
            # Uncomment to enable naxsi on this location
            # include /etc/nginx/naxsi.rules
    }

nginx config中有什么内容?@alexeyten请看我的更新