포트 80에서 순수 TCP 소켓 연결을 포트 80에서도 AWS의 Docker 컨테이너에 연결하려고합니다. 지금까지 다음과 같이했습니다.
로드 밸런서에서 포트 80이 통과 할 수 있도록 올바른 보안 그룹을 설정하십시오. http가 아닌 tcp 연결로 설정됩니다.
EB에서 만든 e2c 인스턴스에서 nginx 로그를 볼 수 있습니다. 보고서는 다음과 같습니다.
172.31.22.8--[2017/01/12 : 20 : 44 : 43 +0000] "... data ..."400173 "-" "-"
HTTP/1.1 400 Bad Request Server: nginx/1.10.1 Date: Thu, 12 Jan 2017 21:05:54 GMT Content-Type: text/html Content-Length: 173 Connection: close <html> <head><title>400 Bad Request</title></head> <body bgcolor="white"> <center><h1>400 Bad Request</h1></center> <hr><center>nginx/1.10.1</center> </body> </html>
다양한 nginx 구성 을 시도했지만 기본적으로 구성 을 시작하기 전에는 다음과 같습니다.
/etc/nginx/nginx.conf
# Elastic Beanstalk Nginx Configuration File
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
log_format healthd '$msec"$uri"$status"$request_time"$upstream_response_time"$http_x_forwarded_for';
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/conf.d/elasticbeanstalk-nginx-docker-upstream.conf
upstream docker {
server 172.17.0.3:80;
keepalive 256;
}
/etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy.conf
server {
listen 80;
gzip on;
gzip_comp_level 4;
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log;
location / {
proxy_pass http://docker;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
데이터가 docker를 실행하는 nginx e2c 인스턴스에 도달하기 때문에 Loadbalancer가 작동하고 있음을 알고 있습니다. 그러나 nginx는 요청을 도커 컨테이너로 전달하지 않습니다. 예, 컨테이너의 포트 80에서 실행되는 애플리케이션이 있습니다. 이는 포트 80에서 0.0.0.0에 바인딩 된 C 소켓입니다. HTTTP가 맞지 않습니까? TCP입니까?
그래서 내 질문에, nginx가 TCP 소켓 연결을 도커 컨테이너로 전달하려면 구성 파일이 무엇이어야합니까 ??
이 글을 올린 지 약 10 개월이 지났습니다. AWS에는 Network Load Balancer라는 것이 없습니다. 나는 그것을 시도하지 않았지만 고정 세션이있는 순수한 TCP 소켓을 허용해야한다고 생각합니다. 그래서 나는 그것을 시도 할 때까지 이것을 닫습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다