2017-01-17 4 views
1
내가 CouchDB를 설치 한

를 사용하여 AWS 인스턴스에 CouchDB를 액세스 할 수 없습니다 성공적으로 SSH를 통해 액세스 할 수 있지만 공개 URL을 인스턴스를 사용하여 액세스 할 수 없습니다.는 AWS 리눅스 인스턴스에 URL

SSH에서 나는 curl -X GET http://127.0.0.1:5984/_all_dbs을 실행할 수 있으며 그것은 내가 기대하는 바대로 ["_replicator","_users","baseball"]입니다.

내가 크롬에서 내 AWS 인스턴스의 URL을 사용하려고하면

: http://ec2-xx-xxx-xx-xx.eu-central-1.compute.amazonaws.com:5984/_utils 크롬은 웹 사이트 연결을 거부했다.

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 

를 내가 얻을 :

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

I cdapache-couchdb-1.6.1하고 INI을 편집하려면 AWS 인스턴스로 SSHing 때

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

루트 디렉토리는 두 개의 항목이 포함 파일을 수행

vim etc/couchdb/local.ini 

이것은 /usr/local/etc/couchdb/local.ini과 동일하다고 가정합니다.

나는 중지 CouchDB를 다시 시작하고 AWS 인스턴스를 다시 시작하지만 여전히 CouchDB를 구성 파일 (들)에서 bind_address을 따기되지 않고있다.

는 IT가

그것은 /usr/local/etc/couchdb/local.inietc/couchdb/local.ini와 동일하지 않습니다 밝혀 SORTED. 바인딩을 올바른 ini에 넣으면 모든 것이 작동합니다!

+2

EC2 인스턴스에 할당 된 보안 그룹에서 포트 '5984'을여셨습니까? –

+0

보안 그룹 중 하나에 다음을 추가했습니다. 모두 TCP TCP 0 - 65535 0.0.0.0/0 –

+0

바인드 주소가 변경된 것을 확인했습니다. 하지만 여전히 ssh를 사용하여 localhost를 사용하여 연결합니다. 당신도 똑같은 것을 확인하고 있지 않습니다. – Seva

답변

4

는 밖에서 볼 수 있도록하는 데 필요한 두 가지가 있습니다 : 당신은 (EC2 인스턴스 속성에서 공인 IP로 표시) 외부 IP 주소에 바인딩하고 방화벽을 열어야합니다. 그래서이 둘 사이에 있어야합니다.

바인드 주소를 0.0.0.0으로 변경했습니다. 이것은 모든 인터페이스에 바인딩하여 바인딩 단계를 처리해야합니다.

하지만 여전히 ssh를 사용하여 localhost를 사용하여 연결합니다.당신도 똑같은 것을 확인하고 있지 않습니다. 곱슬 곱슬 함으로 테스트 할 때 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

관련 문제