我试图让端口80上的纯TCP套接字连接到AWS上的Docker容器也在端口80上。到目前为止我有:
设置正确的安全组,让端口80通过负载均衡器,将其设置为tcp连接,而不是http。
能够在EB创建的e2c实例上看到nginx日志。报告如下:
172.31.22.8 - - [12 / Jan / 2017:20:44:43 +0000]“......数据......”400 173“ - ”“ - ”
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;
}
}
我知道Loadbalancer正在运行,因为数据到达运行docker的nginx e2c实例。但是nginx不会将请求转发到docker容器。是的,有一个应用程序在容器的端口80上运行,它是一个C端口绑定到端口80上的0.0.0.0。所以没有HTTTP正确吗?这是TCP吗?
所以我的问题是,配置文件必须是什么才能让nginx将TCP套接字连接转发到docker容器?
答案 0 :(得分:0)
我发布此消息已经过去了大约10个月。 AWS没有称为网络负载均衡器的东西。我没有尝试过,但认为它应该允许纯TCP套接字与粘性会话。所以我现在关闭它,直到我尝试。