I've django application hosted in docker elastic beanstalk, which uses nginx. For SSL i'm using aws certificate. To redirect http to https i tried " x_forwarded_proto " with trhe nginx inside the docker container but i'm getting a 502 error. here's the nginx config:
server {
listen 80 default_server;
server_name www.example.com;
access_log /home/docker/logs/nginx-access.log;
error_log /home/docker/logs/nginx-error.log;
if ($host !~* ^(www.example.com|example.com)$ ) {
return 444;
}
if ( $http_x_forwarded_proto != 'https' ) {
return 301 https://$host$request_uri;
}
location / {
uwsgi_pass unix:/var/sockets/api.sock;
include /home/docker/server/uwsgi_params; #
}
}
Can anyone suggest a better solution for it.