I want to configure my dockerized django app with nginx and run it on an EC2 instance and I can't get it to work. I am a beginner with nginx.
My error when I do docker-compose -f production.yml up
is:
client sent invalid method while reading client request line, client: 80.153.184.19, server: ec2-XXXXX.eu-central-2.compute.amazonaws.com, request: "�U�F'��Io�q�+!�P��
And I'm like whuat? Isn't there any basic config for this to make it run smoothly?
My nginx config myconf:
server {
set $my_host $host;
if ($host ~ "\d+\.\d+\.\d+\.\d+") {
set $my_host "ec2-XXXXX.eu-central-2.compute.amazonaws.com";
}
listen 80;
server_name ec2-XXXXX.eu-central-2.compute.amazonaws.com;
charset utf-8;
error_log /dev/stdout info;
access_log /dev/stdout;
location / {
proxy_pass http://django:5000;
proxy_set_header Host $my_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
My docker-compose:
version: '3'
#volumes:
# production_caddy: {}
services:
django:
build:
context: .
dockerfile: ./compose/production/django/Dockerfile
image: heatbeat_website_production_django
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
command: /start
nginx:
build:
context: .
dockerfile: ./compose/production/nginx/Dockerfile
ports:
- "0.0.0.0:8080:80"
depends_on:
- django
redis:
image: redis:5.0
my dockerfile for nginx:
FROM tutum/nginx
RUN rm /etc/nginx/sites-enabled/default
COPY ./compose/production/nginx/myconf.conf /etc/nginx/sites-enabled/default
I am extremely grateful for any help... I'm so stuck... Thanks in advance!
0 Answers