Articles of node.js

MongoDB:修复重新configuration的副本集错误 – “Server :: doWork任务:rspipe理器exception:未经授权的数据库:本地锁types:2客户端”

问题:如何修复我的服务器并将其恢复到正常的副本集,而不出现错误消息? 我会提供一个严重的赏金,但所有我的观点都是这样的:( 问题的细节 我在不同的服务器上运行一个3节点的MongoDB副本集(1个主节点,1个从节点,1个仲裁器)。 我正在自动故障转移,确保我的奴隶将被提升到正确的掌握。 当我把主人下来,奴隶接任主人后,我按照指示重新选举我的老主人回到主人( 强迫一个成员为主 )。 从我的新主angular,我跑了: > use admin > db.auth("admin", "mypassword") > config = rs.conf() { "_id" : "foo", "version" : 1, "members" : [ { "_id" : 0, "host" : "A", }, { "_id" : 1, "host" : "B", }, { "_id" : 2, "host" : "C", } ] } […]

在EC2上使用node.js供电的服务器时,如何减lessTCP连接时间?

在分析我的应用程序时,我注意到,在Firebug Net面板中,“连接”时间(即等待TCP连接的时间)始终在70-100毫秒左右。 见下图: 当然在事物的macros伟计划中,100ms不长,但是我看到其他服务以0ms连接时间响应。 所以如果其他服务器可以的话,我应该也可以。 任何想法,我甚至可能会解决这个问题呢?

Nginx子域没有路由到Node.js

我有一个我想通过Nginx代理到Node.js的子域。 domain.tld目前是通过/opt/nginx/conf/nginx.conf路由的标准方式。 但是,我也想要subdomain.domain.tld路由到domain.tld:8000 。 为此,我将以下内容放在/etc/nginx/sites-available/subdomain.domain.tld.conf : http{ server { listen 0.0.0.0:80; server_name subdomain.tld.com; access_log /var/log/nginx/subdomain.domain.log; location / { proxy_pass http://127.0.0.1:8000; } } } Nginx似乎启动正常。 子域的名称服务器configuration正确。 我究竟做错了什么? 预先感谢任何帮助。 编辑:另外,我将文件从sites-available/到sites-enabled/ 。 编辑: /opt/nginx/conf/nginx.conf的确切内容: http://pastebin.com/wZJFPx7H 编辑:从nginx开始的错误消息: Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already […]

微EC2实例之后,即使有pipe理员,Node应用程序也会崩溃

我正在使用主pipe在微EC2实例上启动我的node.js应用程序。 但是,该应用只能保持运行一段时间,直到最终closures。 不完全确定该应用程序运行多久,但我猜大约几个小时左右。 有时less一些。 我的问题是,我应该在远程服务器上的位置来debugging这种问题? 我正在运行亚马逊Linux AMI。

为具有自己的域的多个node.js应用程序configurationnginx

我有一个节点的Web应用程序和我的nginx在debian挤压上运行。 现在我想添加一个自己的域名,但是当我这样做,只有第一个应用程序被提供,即使我去第二个域名,我只是被redirect到第一个Web应用程序。 希望你看到我在这里做错了: example1.conf: upstream example1.com { server 127.0.0.1:3000; } server { listen 80; server_name www.example1.com; rewrite ^/(.*) http://example1.com/$1 permanent; } # the nginx server instance server { listen 80; server_name example1.com; access_log /var/log/nginx/example1.com/access.log; # pass the request to the node.js server with the correct headers and much more can be added, see nginx config […]

你用nginx直接expression节点应用程序有什么好处?

我目前正在使用express来托pipe我的节点应用程序(在一个简单的代理将它们closures之后) var httpProxy = require('http-proxy'); var http = require('http'); var express = require('express'); httpProxy.createServer(function (req, res, proxy) { var nodeVhosts = ["www.site.com"] var host = req.headers['host']; var port = nodeVhosts.indexOf(host) > -1 ? 8080 //must be a node vhost so pass it to :8080 : 9000; //must be an apache vhost so pass it to […]

NodeJS Supervisord Hashlib

我的NodeJS应用程序有问题。 问题是包含的库Hashlib我已经遵循了超过10次的安装说明。 得到回购的克隆,做和做安装。 NodeJS安装在默认path中,这是一个棘手的问题: 当我启动节点app.js它的作品,完美。 当我configuration我的Supervisord运行相同的用户,具有相同的configuration文件,我在其他系统工作,我得到的NodeJS找不到hashlib时,问题开始。 module.js:337 throw new Error("Cannot find module '" + request + "'"); ^ Error: Cannot find module 'hashlib' 我疯了,我能做什么? 为什么我的用户从控制台启动节点效果很好,但不是supervisord? 谢谢!

使用Varnish和nginx时redirect非httpsstream量

我正在使用Stunnel,Varnish和nginx与nodejs应用程序,并且在将非https页面( http://manager.domain.com )redirect到它们各自的https页面( https://manager.domain。 com )。 我只是卡在一个redirect循环,因为所有的stream量首先通过清漆。 这个设置的主要原因是使用ssl的套接字。 Stunnel侦听端口443.它终止SSL连接,并将stream量传递给端口80上的Varnish。Varnish侦听端口80,并根据需要拆分81上的Nginx和3000上的Node.js之间的其他stream量.Nginx侦听端口81.它服务静态文件和其他非Node.js页面。 这里是nginx conf文件 upstream nodejs { server 127.0.0.1:3000; server 127.0.0.1:3000; } server { listen 81; server_name www.domain.net; rewrite ^(.*) http://domain.com$1 permanent; } server { listen 81; server_name manager.domain.com; rewrite ^(.*) https://manager.domain.com$1 permanent; } server { listen 81; server_name domain.com manager.domain.com help.domain.com; access_log /srv/www/domain.com/logs/access.log timed; error_log /srv/www/domain.com/logs/error.log info; […]

nginx与nodejs

我想在Ubintu服务器12.4上安装nodejs和nginx,并设置它们以进行可靠的工作。 你能否提供以下问题的答案: 我应该在哪里安装nodejs? 我应该在哪里findnodejs项目文件以及我需要设置的权限? 我应该如何设置nginx作为nodejs的代理?

HAProxy正在caching转发?

我试图build立一个服务器结构的应用程序,我正在build立在Node.js与socket.io。 我的设置是: HAProxy前端转发到 -> apache2 as default backend (or nginx, is apache in this local test) -> node.js app if the url has socket.io in the request AND a domain name 我有这样的东西: global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 4096 user haproxy group haproxy daemon defaults log global mode http maxconn 2000 contimeout […]