如何在http nginx dockerpopup的beanstalk中将httpredirect到https
我有一个django应用程序托pipe在docker elastic beanstalk中,它使用nginx。 对于SSL我使用aws证书。 将httpredirect到https我试图在docker容器中使用trhe nginx的“x_forwarded_proto”,但是我得到了一个502错误。 这里是nginxconfiguration:
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; # } }
任何人都可以提出一个更好的解决scheme。
find一个解决scheme,只需添加
if ( $http_x_forwarded_proto != 'https' ) { return 301 https://$host$request_uri; }
到eb实例的nginxconfiguration。
这真的是一个nginx问题(添加适当的标签)。
你的configuration似乎很复杂。 从这个开始。 这是我用来redirectHTTP端口80stream量到TLS / SSL端口443stream量。
access_log /home/docker/logs/nginx-access.log; error_log /home/docker/logs/nginx-error.log; server { listen 80; server_name www.example.com; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name www.example.com; location / { root /usr/share/nginx/html; index index.html; } }
- AWS Elastic Beanstalk中的Docker:在$ PATH中找不到可执行文件“
- Docker镜像里面的进程是否仍然需要pipe理?
- Elastic Beanstalk和Dockerfile ARG指令
- 在Elastic Beanstalk的Docker中的cron作业中访问S3
- Elastic Beanstalk本地环境(与Docker)连接被拒绝
- 在AWS EBS microservice docker环境中使用Kafka,以避免丢失用户请求并处理更多并发点击
- “nginx-proxy”docker image socket volume not mounted
- AWS Elastic Beanstalk忽略了我的Dockerrun.aws.json文件
- 在Elastic Beanstalk中暴露Docker的多个端口