通过 nginx 作为代理连接到 AWS Neptune 服务器
Connect to AWS Neptune server via nginx as proxy
AWS Neptune 专供 VPC 使用。我们无法从 VPC 外部访问它。所以我在同一个VPC中创建了一个实例,并在其中安装了nginx。我像这样配置了 nginx(跳过了侧面配置部分)。
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;
}
}
}
当我尝试访问 Neptune 时,每次都会出现此错误。
{"requestId":"","code":"BadRequestException","detailedMessage":"Bad request."}
如果有人遇到这种问题,请帮助我。
你能试试这个,看看它是否有效?我给它做了一个快速测试,它似乎工作正常。
http {
upstream neptune {
server <neptune_endpoint_without_protocol>:8182;
keepalive 15;
}
sendfile on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server {
listen 8182;
error_log /var/log/nginx/neptune.error.log;
access_log /var/log/nginx/neptune.access.log;
location / {
proxy_pass http://neptune;
proxy_redirect off;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}
}
虽然 AWS Neptune 有 http 端点,但我尝试使用 nginx,但它没有用。所以我尝试了 nginx 提供的不同指令。 stream 指令是我想要的。如果将来有人需要相同的解决方案,请发布答案。
stream {
server {
listen 8182;
proxy_pass <neptune_endpoint>:8182;
}
}
AWS Neptune 专供 VPC 使用。我们无法从 VPC 外部访问它。所以我在同一个VPC中创建了一个实例,并在其中安装了nginx。我像这样配置了 nginx(跳过了侧面配置部分)。
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;
}
}
}
当我尝试访问 Neptune 时,每次都会出现此错误。
{"requestId":"","code":"BadRequestException","detailedMessage":"Bad request."}
如果有人遇到这种问题,请帮助我。
你能试试这个,看看它是否有效?我给它做了一个快速测试,它似乎工作正常。
http {
upstream neptune {
server <neptune_endpoint_without_protocol>:8182;
keepalive 15;
}
sendfile on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server {
listen 8182;
error_log /var/log/nginx/neptune.error.log;
access_log /var/log/nginx/neptune.access.log;
location / {
proxy_pass http://neptune;
proxy_redirect off;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}
}
虽然 AWS Neptune 有 http 端点,但我尝试使用 nginx,但它没有用。所以我尝试了 nginx 提供的不同指令。 stream 指令是我想要的。如果将来有人需要相同的解决方案,请发布答案。
stream {
server {
listen 8182;
proxy_pass <neptune_endpoint>:8182;
}
}