2017-01-17 5 views
1

AWS LinuxインスタンスにCouchDBをインストールし、SSH経由で正常にアクセスできますが、インスタンスの一般公開URLを使用してアクセスできません。URLを使用してAWSインスタンスのCouchDBにアクセスできない

私はcurl -X GET http://127.0.0.1:5984/_all_dbsを実行することができ、それは私には私が期待している["_replicator","_users","baseball"]を与える。

ChromeでAWSインスタンスのURLを使用しようとすると:http://ec2-xx-xxx-xx-xx.eu-central-1.compute.amazonaws.com:5984/_utils Chromeは接続を拒否しています

CORSを追加するためにCouchDBのlocal.iniファイルを編集しました。 local.iniは次のようになります。

; CouchDB Configuration Settings 
 

 
; Custom settings should be made in this file. They will override settings 
 
; in default.ini, but unlike changes made to default.ini, this file won't be 
 
; overwritten on server upgrade. 
 

 
[couchdb] 
 
;max_document_size = 4294967296 ; bytes 
 

 
[httpd] 
 
enable_cors = true 
 
bind_address = 0.0.0.0 
 

 
[cors] 
 
origins = * 
 

 
;port = 5984 
 
;bind_address = 127.0.0.1 
 
; Options for the MochiWeb HTTP server. 
 
;server_options = [{backlog, 128}, {acceptor_pool_size, 16}] 
 
; For more socket options, consult Erlang's module 'inet' man page. 
 
;socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}] 
 

 
; Uncomment next line to trigger basic-auth popup on unauthorized requests. 
 
;WWW-Authenticate = Basic realm="administrator" 
 

 
; Uncomment next line to set the configuration modification whitelist. Only 
 
; whitelisted values may be changed via the /_config URLs. To allow the admin 
 
; to change this value over HTTP, remember to include {httpd,config_whitelist} 
 
; itself. Excluding it from the list would require editing this file to update 
 
; the whitelist. 
 
;config_whitelist = [{httpd,config_whitelist}, {log,level}, {etc,etc}] 
 

 
[query_servers] 
 
;nodejs = /usr/local/bin/couchjs-node /path/to/couchdb/share/server/main.js 
 

 

 
[httpd_global_handlers] 
 
;_google = {couch_httpd_proxy, handle_proxy_req, <<"http://www.google.com">>} 
 

 
[couch_httpd_auth] 
 
; If you set this to true, you should also uncomment the WWW-Authenticate line 
 
; above. If you don't configure a WWW-Authenticate header, CouchDB will send 
 
; Basic realm="server" in order to prevent you getting logged out. 
 
; require_valid_user = false 
 

 
[log] 
 
;level = debug 
 

 
[log_level_by_module] 
 
; In this section you can specify any of the four log levels 'none', 'info', 
 
; 'error' or 'debug' on a per-module basis. See src/*/*.erl for various 
 
; modules. 
 
;couch_httpd = error 
 

 

 
[os_daemons] 
 
; For any commands listed here, CouchDB will attempt to ensure that 
 
; the process remains alive. Daemons should monitor their environment 
 
; to know when to exit. This can most easily be accomplished by exiting 
 
; when stdin is closed. 
 
;foo = /path/to/command -with args 
 

 
[daemons] 
 
; enable SSL support by uncommenting the following line and supply the PEM's below. 
 
; the default ssl port CouchDB listens on is 6984 
 
; httpsd = {couch_httpd, start_link, [https]} 
 

 
[ssl] 
 
;cert_file = /full/path/to/server_cert.pem 
 
;key_file = /full/path/to/server_key.pem 
 
;password = somepassword 
 
; set to true to validate peer certificates 
 
verify_ssl_certificates = false 
 
; Path to file containing PEM encoded CA certificates (trusted 
 
; certificates used for verifying a peer certificate). May be omitted if 
 
; you do not want to verify the peer. 
 
;cacert_file = /full/path/to/cacertf 
 
; The verification fun (optional) if not specified, the default 
 
; verification fun will be used. 
 
;verify_fun = {Module, VerifyFun} 
 
; maximum peer certificate depth 
 
ssl_certificate_max_depth = 1 
 

 
; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All requests to 
 
; the Virual Host will be redirected to the path. In the example below all requests 
 
; to http://example.com/ are redirected to /database. 
 
; If you run CouchDB on a specific port, include the port number in the vhost: 
 
; example.com:5984 = /database 
 
[vhosts] 
 
;example.com = /database/ 
 

 
[update_notification] 
 
;unique notifier name=/full/path/to/exe -with "cmd line arg" 
 

 
; To create an admin account uncomment the '[admins]' section below and add a 
 
; line in the format 'username = password'. When you next start CouchDB, it 
 
; will change the password to a hash (so that your passwords don't linger 
 
; around in plain-text files). You can add more admin accounts with more 
 
; 'username = password' lines. Don't forget to restart CouchDB after 
 
; changing this. 
 
[admins] 
 
;admin = mysecretpassword

:UPDATE:

ランニング:

netstat -a -n | grep 5984 

は私が手:

tcp  0  0 127.0.0.1:5984    0.0.0.0:*     LISTEN 

127.0.0.1ですが、etc/couchdb/local.inietc/couchdb/default.iniの両方のバインディングを0.0.0.0に設定しているので、0.0.0.0にする必要があります。

couchdbが他の場所から設定を取得しているように見えますか?私は実行すると:

couchdb -c 

私が取得:

/usr/local/etc/couchdb/default.ini 
/usr/local/etc/couchdb/local.ini 

AWSインスタンスにSSHingすると、ルートディレクトリには2つのエントリが含まれますapache-couchdb-1.6.1

apache-couchdb-1.6.1 apache-couchdb-1.6.1.tar.gz 

I cdをしてiniファイルを編集しますファイルdo:

vim etc/couchdb/local.ini 

これは/usr/local/etc/couchdb/local.iniと同じですか?

couchdbを停止して再起動してAWSインスタンスを再起動しましたが、couchdbはconfigファイルからbind_addressを取得していません。

のIT

ソートそれは/usr/local/etc/couchdb/local.inietc/couchdb/local.iniと同じではないことが判明します。バインディングを正しいiniに入れると、すべて動作します!

+2

EC2インスタンスに割り当てられたセキュリティグループにポート「5984」を開いていましたか? –

+0

セキュリティグループの1つに以下を追加しました。 すべてTCP TCP 0 - 65535 0.0.0.0/0 –

+0

バインドアドレスを変更したのを確認しました。しかし、引き続きsshを使ってlocalhostを使って接続します。あなたは同じ事をチェックしていません。 – Seva

答えて

4

外に見えるようにするために必要なものは2つだけです。外部IPアドレス(EC2インスタンスプロパティのパブリックIPとして表示)にバインドし、ファイアウォールで開く必要があります。だから、これらの2つの間になければなりません。

バインドアドレスを0.0.0.0に変更しました。これは、すべてのインタフェースをバインドすることによってバインディングステップを処理する必要があります。

でも、sshを使用してlocalhostを使用して接続します。あなたは同じ事をチェックしていません。 curlでテストしようとすると、127.0.0.1ではなく、マシンのIPアドレスを使用してください。 EC2インスタンスのプロパティでPublic IPとして示されているものでなければなりません。しかし疑問がある場合は、ifconfig -aを使用して、あなたが持っているIPアドレスを把握してください。次のコマンドnetstat -a -n | grep 5984を実行することによって、実際にバインドされているインターフェイスを確認することもできます。 LISTEN(127.0.0.1:5984ではなく)として0.0.0.0:5984(または*:5984)を表示する必要があります。それ以外の場合は、正しいポートにバインドされていないため、CouchDbの設定ファイルでその理由を確認する必要があります。また、CouchDBが実際に編集している設定を使用しているかどうか確認することもできます。

ファイアウォール側で、正しいセキュリティグループで開いていることを確認します。 EC2インスタンスの「セキュリティグループ」プロパティに示されているものでなければなりません。また、開いたルールはインバウンドでなければなりません。

インスタンス・ファイアウォールが何度もジャンプしてトラブルを引き起こします。しかし、私はWindowsマシンでこの問題を抱えていました。私はそれがAWS Linuxマシンでは無効になっていると信じています(少なくとも、何も調整する必要はありませんでした。セキュリティグループのルールは常に十分でした)。

これはまだ動作しない場合。私はtelnetで接続しようとするかどうか試してみることを提案するしかありません。ブラウザーが正確なステージを誤って報告して、平均的なユーザーにとってよりシンプルになることがあります。 telnetで接続することはより低レベルのテストですが、コロンではなくtelnetのためのスペースでポートを区切る必要があることに注意してください。 telnet 1.2.3.4 5984ここで、1.2.3.4はサーバーのIPアドレスです。

+0

私はそれをソートしました!私はiniファイルの間違ったコピーを編集していました(私の更新された質問を参照)。私はこれまであなたの助けなしにこれを得ていなかったでしょう。そうすれば、iniファイルの正しいパスを含めるように答えを修正したいなら、あなたに報酬を与えます。あなたの助けと忍耐のために多くのおかげです! –

+0

@Bill申し訳ありませんが、私は数日間、stackoverflowをチェックしていませんでした。私は、あなたが正しい方向に向けるのを助けたと信ずる議論からの重要な詳細を含めるために、少し答えを整理しました。しかし、私は、質問へのあなたの編集は、私が思い付くことができる何かよりはるかに良いと信じています。あなたがそうしたいと思うなら私の答えを編集できるはずです。しかし、編集したものが潜在的な読者が後で問題の内容を把握するのが難しくなるような気がするので、私はむしろそのままにしておきます。 – Seva

関連する問題