6

Elastic Beanstalk에서 API와 Api 게이트웨이를 연결하려고합니다. Api Gateway에서만 내 api를 액세스 가능하게하고 싶습니다. 백엔드에서 클라이언트 측 SSL 인증서 인증을 사용합니다 (예 : aws publication Link : http://docs.aws.amazon.com/es_es/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html). 그래서 내 arquitecture은 다음과 같이이다 :Elastic Beanstalk (클라이언트 측 SSL 인증서)와의 Api 게이트웨이 연결

API의 게이트웨이 -> ELASTIC로드 BALANCER-> EC2 (ELASTIC 콩나무)

내 EC2 기계는 한 Nginx에와 루비.

연결은 다음과 같이 작동 :

API 게이트웨이 -> (80 포트) -> ELASTIC로드 밸런서 -> (443 PORT) -> Nginx에 -> 루비

나는 클라이언트 인증의를하고있는 중이 야 NGINX. 브라우저를 사용하여 Elastic Load Balancer에 액세스하면 400 Bad Request - NGINX 오류가 표시됩니다. 필요한 SSL 인증서가 전송되지 않았습니다 (이는 인증서를 보내지 않았기 때문에 정확합니다). 그러나 Api 게이트웨이를 사용하여 액세스하고 클라이언트 인증서를 보낼 때 같은 오류가 발생합니다 (이유를 이해하지 못함). 내가 Nginx와의 SSL 연결을 구성 할 때

, 나는 탄성로드 밸런서의 포트 구성 (인은 (아마도이 ​​문제는?) 저에 의해 서명 된 SSL 인증서 내 문제에 대한

기타 추적 할 수없는 가망 원인이됩니다 사용하고 있습니다 사진). 백엔드 인증 : 사용 안함. 이게 문제 야? Pictura Port Config ELB

내의 nginx의 구성은 다음과 같습니다

upstream my_app { 
    server unix:///var/run/puma/my_app.sock; 
} 

log_format healthd '$msec"$uri"' 
       '$status"$request_time"$upstream_response_time"' 
       '$http_x_forwarded_for'; 

server { 
listen  443 ssl; 
listen  [::]:443 ssl; 
server_name localhost; 
root   /usr/share/nginx/html; 

ssl on; 
ssl_certificate /etc/nginx/ssl/dev.crt; 
ssl_certificate_key /etc/nginx/ssl/dev.key; 
ssl_trusted_certificate /etc/nginx/ssl/api-gateway.pem; 
ssl_client_certificate /etc/nginx/ssl/api-gateway.pem; 
ssl_verify_client on; 

ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; 
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; 
ssl_prefer_server_ciphers on; 
if ($ssl_client_verify = FAILED) { 
     return 495; 
} 
if ($ssl_client_verify = NONE) { 
    return 402; 
} 
if ($ssl_client_verify != SUCCESS) { 
    return 403; 
} 
try_files $uri/index.html $uri @my_app; 
    location @my_app { 
    proxy_set_header Host $host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Host $server_name; 
    proxy_set_header Client-IP $remote_addr; 
      proxy_pass  http://my_app; 
    proxy_set_header X-Client-Verify $ssl_client_verify; 
    } 
# Load configuration files for the default server block. 
include /etc/nginx/default.d/*.conf; 
location/{ 
    proxy_pass http://my_app; # match the name of upstream directive which is defined above 
    proxy_set_header Host $host; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header gonzalo1 $ssl_client_verify; 
} 
error_page 404 /404.html; 
    location = /40x.html { 
} 
error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
} 

}

+0

doc 링크는 Api Gtw 클라이언트 인증서로 Beanstalk을 호출하지 않고 클라이언트 인증서로 Api Gtw를 호출하는 것에 관한 것입니다. 내가 뭔가를 놓친 건가? Api Gtw 클라이언트 인증서가 Api Gtw를 호출하지 않은 이유는 Api Gtw와 다른 것을 호출하지 않기 때문입니다. – fsenart

+0

@fsenart, 내가 아는 바에 따르면,이 경우의 인증서는 Api 게이트웨이에서 백엔드로 전화를 걸기위한 것이고 백엔드에서는 Api 게이트웨이로부터의 요청임을 인증 할 수 있습니다. 링크의 첫 번째 단락에서 매우 명확합니다. –

+0

아니요, @fsenart, 클라이언트 인증서는 API 게이트웨이가 앱 서버에 자신을 인증하는 데 사용됩니다. –

답변

2

아마존 API 게이트웨이는 통합 엔드 포인트에 대한 자체 서명 된 인증서를 지원하지 않습니다. Amazon 인증서 관리자의 인증서 또는 Let's Encrypt을 사용해 보셨습니까?

+0

그것은 또한 사실이지만,이 특정 문제의 원인은 아닙니다. 이것은 해결책이 여기에 새로운 오류를 만들 때 OP의 다음 질문에 대한 해답이 될 것입니다. :) –

+0

안녕하세요, 당신이 nginx를 사용하여 어떻게 이것을 달성 할 수 있습니까? –

+0

@Stefano AWS 인증서 관리자를 사용하여 클라이언트 측 인증서 (API 게이트웨이에서 제공하는 인증서)를 어떻게 푸시합니까? ? 아이디어, 생각? –