我有一个AWS EMR,我一直在尝试配置路径(/ hbase)以通过NGINX访问EMR中的HBase。为了实现我的目标,我创建了一个配置文件/etc/nginx/conf.d/hbase.conf
。
server {
charset utf-8;
listen 80;
#Hbase works when location /hbase/ is replaced with location /.
It does not work like below.
location /hbase/
{
proxy_pass http://localhost:16010;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
这是我在电子病历中的/etc/nginx/nginx.conf
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
log_format main '$remote_addr - [$time_local] "$request" '
'$status "$http_referer" '
'"$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
# HTTPS server
server {
listen 18888 ssl;
ssl_certificate /etc/ssl/certs/nginx.crt;
ssl_certificate_key /etc/ssl/certs/nginx.key;
server_name localhost;
location /webhdfs/v1/user {
proxy_pass http://localhost:14000;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
}
location /sessions {
proxy_pass http://localhost:8998;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
}
location /batches {
proxy_pass http://localhost:8998;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
}
location /proxy {
proxy_pass http://ip-10-100-0-4.ec2.internal:20888;
proxy_read_timeout 1800;
proxy_connect_timeout 1800;
}
} #end server tag
} #end http tag
问题是,当我按下http://tempmyserverurl/hbase
时,出现了 404 Not Found 错误。但是,当我在hbase.conf
中将位置 / hbase 更新为 / 时,它会重定向到master_status
,并且可以访问HBase UI。
我只是想让NGINX用location /hbase
加载HBase。我尝试过使用其他服务器,并提到了此EMR服务器的代理服务器通行证,但是它不起作用。
有人可以帮助我朝正确的方向发展吗?帮我弄清楚我在这里想念的东西。
谢谢。
答案 0 :(得分:0)
给予
#include <regex>
#include <string>
#include <iostream>
#include <iterator>
#include <algorithm>
int main() {
const std::string s = "user1:192.168.0.1|user2:192.168.0.2|user3:192.168.0.3";
std::regex r(R"_((user\d+)\:((?:\d{1,3}\.?){4}))_");
struct record {
std::string username;
std::string ip;
};
std::vector<record> records;
std::transform(
std::sregex_iterator{ s.begin(), s.end(), r }, std::sregex_iterator{},
std::back_inserter(records),
[](auto& sm) -> record { return { sm[1],sm[2] }; }
);
std::transform(
records.begin(), records.end(),
std::ostream_iterator<std::string>{std::cout, "\n"},
[](auto& rec) { return rec.username + ':' + rec.ip; }
);
}
对location /hbase
{
proxy_pass http://localhost:16010;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
的请求将像http://example.com/hbase/some/path
一样proxied
至http://localhost:16010
,这很可能不存在,因为http://localhost:16010/hbase/some/path
在URL中,因此404错误。
来自https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
如果URI和地址一起指定,它将替换请求URI中与location参数匹配的部分。
hbase
在此示例中,对location /hbase
{
proxy_pass http://localhost:16010/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
的请求将像http://example.com/hbase/some/path
到proxied
到http://localhost:16010
,因此从网址中删除了http://localhost:16010/some/path
,这很可能解决了问题。