Search code examples
nginxamazon-neptune

Connect to AWS Neptune server via nginx as proxy


AWS Neptune is private to VPC. We can't access it from outside the VPC. So I created one instance in the same VPC and installed nginx in it. I configured nginx like this (side config parts skipped).

http {
  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
  sendfile            on;
  #tcp_nopush          on;
  tcp_nodelay         on;
  keepalive_timeout   65;
  types_hash_max_size 2048;
  server {
    listen 8182;
    error_log  /var/log/nginx/neptune.error.log main;
    access_log  /var/log/nginx/neptune.access.log main;
    location / {
      proxy_pass <neptune_endpoint>:8182;
    }
  }
}

When I tried to access Neptune, every time I am getting this error.

{"requestId":"","code":"BadRequestException","detailedMessage":"Bad request."}

If anybody faced this kind of issue, please help me out.


Solution

  • Although AWS Neptune has http endpoint, while I tried with nginx, it didn't work. So I tried different directives that nginx is offering. And stream directive is the one I wanted. Posting answer if anybody needs the same solution in future.

    stream {
      server {
        listen 8182;
        proxy_pass <neptune_endpoint>:8182;
      }
    }