I am trying to let an pure TCP Socket connection on port 80 through to an Docker container on AWS also on port 80. So far i have:
Setup the correct security groups to let port 80 through on the Load balancer, it is set to an tcp connection, not http.
Been able to see the nginx logs on the e2c instance create by EB. The report the following:
172.31.22.8 - - [12/Jan/2017:20:44:43 +0000] "...data..." 400 173 "-" "-"
- And then the program creating the socket reports:
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>
I have tried many different nginx configurations.But at default, before I began the configs was as follows:
/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;
}
}
I know the Loadbalancer is working because the data reaches the nginx e2c instance that runs docker. But nginx does not forward the request to the docker container. Yes there is an application running on port 80 of the container, it is a C socket bound to 0.0.0.0 on port 80. So no HTTTP correct? it is TCP?
So my question, what must the configuration file be for nginx to forward TCP socket connection to the docker container??