2017-05-08 114 views
0

您好,我正在尝试部署我的第一个MEAN应用程序。无法从外部连接到mongo

所有的作品,但在本地主机。

从外面,我可以看到前端(angular2)

我的问题是,我不能登录到我的应用程序从外面。当我试图创建账户或登录存在ACC我有

ERR_CONNECTION_REFUSED

这是我mongod.conf

# mongod.conf 

# Where to store the data. 

# Note: if you run mongodb as a non-root user (recommended) you may 
# need to create and set permissions for this directory manually, 
# e.g., if the parent directory isn't mutable by the mongodb user. 
dbpath=/var/lib/mongodb 

#where to log 
logpath=/var/log/mongodb/mongod.log 

logappend=true 
smallfiles=true 

port = 27017 

# Listen to local interface only. Comment out to listen on all interfaces. 
bind_ip = 127.0.0.1 

# Disables write-ahead journaling 
# nojournal = true 

# Enables periodic logging of CPU utilization and I/O wait 
#cpu = true 

# Turn on/off security. Off is currently the default 
#noauth = true 
#auth = true 

# Verbose logging output. 
#verbose = true 

# Inspect all client data for validity on receipt (useful for 
# developing drivers) 
#objcheck = true 

# Enable db quota management 
#quota = true 

# Set oplogging level where n is 
# 0=off (default) 
# 1=W 
# 2=R 
# 3=both 
# 7=W+some reads 
#diaglog = 0 

# Ignore query hints 
#nohints = true 

# Enable the HTTP interface (Defaults to port 28017). 
#httpinterface = true 

# Turns off server-side scripting. This will result in greatly limited 
# functionality 
#noscripting = true 

# Turns off table scans. Any query that would do a table scan fails. 
#notablescan = true 

# Disable data file preallocation. 
#noprealloc = true 

# Specify .ns file size for new databases. 
# nssize = <size> 

# Replication Options 

# in replicated mongo databases, specify the replica set name here 
#replSet=setname 
# maximum size in megabytes for replication operation log 
#oplogSize=1024 
# path to a key file storing authentication info for connections 
# between replica set members 
#keyFile=/path/to/keyfile 

而且还有我的config.json文件

{ 
    "connectionString": "mongodb://127.0.0.1:27017/mydb", 
    "apiUrl": "http://localhost:4000", 
    "secret": "REPLACE THIS WITH YOUR OWN SECRET, IT CAN BE ANY STRING" 
} 

我正在使用debian jessie

+0

你能否提供更多的细节,你的意思是'deploy'?什么改变了?你能否也提供你的nginx配置? – pe3k

回答

0

从您的描述看来,您的MongoDB没有部署在本地主机上。如果是这种情况,您需要更新您的配置。

请注意bind_ip参数(https://docs.mongodb.com/manual/reference/configuration-options/)。如果你在不同的服务器上部署应用程序,mongodb-server公共IP应该在这里。应用程序连接字符串也需要更新以反映正确的IP。

但是请确保在公开部署时(至少验证https://docs.mongodb.com/manual/tutorial/enable-authentication/)正确设置了您的安全选项!

+0

我已经在我的debian服务器上安装了mongodb,这里也是节点等。我正在使用nginx。 我从外面看到我的前端,但是当我尝试登录时,我收到错误连接而被拒绝 –