티스토리 뷰

VPC내부에 설정된 서비스의 경우 외부 인터넷을 통해 통신할 수 없다. Amazon Neptune DB 클러스터는 VPC에서만 생성할 수 있다. local 환경에서 AWS Neptune과 통신하기 위해 EC2를 AWS Neptune DB 클러스터와 같은 VPC에 생성하고 리버스 프록시 서버로 설정했다.

 

AWS Neptune DB 클러스터 endpoint는 https 프로토콜을 사용해야하여 Let's encrypt로 SSL 인증서를 생성하여 리버스 프록시 서버에 SSL 인증서를 등록했다.

EC2에 nginx 설치

$ sudo vi /etc/yum.repos.d/nginx.repo 
# nginx.repo
[nginx] name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/gpgcheck=0
enabled=1
yum install nginx

Let’s encrypt 설치

let’s encrypt는 https 접속을 위한 SSL 인증서를 무료로 생성할 수 있는 서비스이다.

wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
sudo cp certbot-auto /usr/bin/

amazon web services - Let’s encrypt certbot on AWS Linux - Stack Overflow

인증서 생성

AWS EC2를 proxy 서버로 사용하기 위해서는 EC2를 생성하고 public IP를 route53에 A recode로 등록한다.

certbot에서 SSL 인증서를 생성할 때 route53에 등록한 domain과 IP를 확인한다. 또한, EC2의 security group의 80, 443 port를 열고 아래 명령을 실행해야한다.

# get and install SSL
sudo certbot --nginx

# only get SSL
sudo certbot certonly --nginx

nginx.conf 설정

let’s encrypt를 통해 SSL 인증서를 받은 후 nginx 서버에 SSL 인증서를 아래와 같이 등록한다.

# /etc/nginx/nginx.conf
stream {
  upstream stream_backend {
         server <neptune_endpoint_whithout_protocol>:8182;
  }

  log_format basic '$remote_addr [$time_local] '
                     '$protocol $status $bytes_sent $bytes_received '
                     '$session_time';

  access_log  /var/log/nginx/access.log basic;
  error_log  /var/log/nginx/error.log debug;

  server {
        listen 8182 ssl;
        proxy_connect_timeout 5s; # websocket을 사용하는 경우 설정값을 더 길게 설정해야한다.
        proxy_ssl on;
        proxy_timeout 20s; # websocket을 사용하는 경우 설정값을 더 길게 설정해야한다.
        proxy_pass stream_backend;

      ssl_certificate /etc/letsencrypt/live/proxy.tagdetail.com/fullchain.pem; # managed by Certbot
      ssl_certificate_key /etc/letsencrypt/live/proxy.tagdetail.com/privkey.pem; # managed by Certbot
      include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  }
}

Gremlin console을 사용하는 경우 아래 링크를 따라 설정해야 한다.

서명 버전 4 서명으로 Gremlin 콘솔을 사용하여 Neptune에 연결 - Amazon Neptune

Reference

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함