{"comment":{"created_at":"2011-10-13T06:37:18Z","body":"Hey, turns out it was completely a different issue. Non-root users can't bind to ports under 1024. By running as root, i.e. removing -u www-data it now works as expected.\r\n\r\n","updated_at":"2011-10-13T06:37:18Z","url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/comments/2391695","id":2391695,"user":{"avatar_url":"https://secure.gravatar.com/avatar/caeb7da8621bccbfdb00a166ec6c46bb?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/geuis","id":53883,"login":"geuis"}},"action":"created","issue":{"number":128,"created_at":"2011-10-13T01:28:10Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"When I run the proxy directly, it seems to work fine as long as the session remains open.\r\n\r\nI'm having a hard time getting my proxy server to stay alive when its being started with Upstart or as a background process. Basically I can see the process start and then after a few seconds it dies. Upstart then continues to restart the proxy but it continues to bounce.\r\n\r\nThe other way to background a process is:\r\n\r\n     sudo node app.js &\r\n\r\nI run multiple node.js services on the same server and start them up using Upstart with no issues.\r\n\r\nFirst, here is my proxy server:\r\n\r\nvar http = require('http'),\r\n    httpProxy = require('http-proxy'),\r\n    fs = require('fs');\r\n\r\nfs.readFile(__dirname + '/routes.json', function (err, data) {\r\n\r\n if (err) throw err;\r\n\r\n    var options = {\r\n        hostnameOnly: true,\r\n        router: JSON.parse(data.toString())\r\n    };\r\n    var proxyServer = httpProxy.createServer(options);\r\n\r\n    proxyServer.listen(80);\r\n\r\n});\r\n\r\nNext, my routes.json file (domain changed, but localhost and port are the same):\r\n\r\n{\r\n    \"mysite.com\": \"127.0.0.1:9999\"\r\n}\r\n\r\nThe routes.json file is loaded and parsed as json and this is used for the router options.\r\n\r\nFinally, this is my Upstart conf which is identical except for the app.js paths to several other conf files I have that work as expected.\r\n\r\ndescription \"nodeproxy node.js server\"\r\n\r\nstart on started\r\nstop on shutdown\r\n\r\nrespawn\r\n\r\nscript\r\n    # We found $HOME is needed. Without it, we ran into problems\r\n    export HOME=\"/usr/local/apps/nodeproxy/\"\r\n\r\n    exec sudo -u www-data /usr/local/bin/node /usr/local/apps/nodeproxy/app.js \r\n\r\nend script\r\n\r\n\r\nI have done extensive checking including:\r\nError logging\r\nFile permissions on app.js and nodeproxy.conf\r\nFile owners\r\nRunning app.js with Upstart and as a background process using &\r\n\r\nI'm really at a loss as to why this is running fine when I have the session open but refuses to be backgrounded.\r\n\r\nThanks!","comments":4,"title":"Proxy server dies when started with Ubuntu Upstart or as background process","updated_at":"2011-10-13T06:37:18Z","url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/128","id":1896473,"assignee":null,"milestone":null,"closed_at":"2011-10-13T06:37:18Z","user":{"avatar_url":"https://secure.gravatar.com/avatar/caeb7da8621bccbfdb00a166ec6c46bb?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/geuis","id":53883,"login":"geuis"},"html_url":"https://github.com/nodejitsu/node-http-proxy/issues/128","labels":[],"state":"closed"},"legacy":{"issue_id":1896473,"comment_id":2391695}}