【发布时间】:2020-12-10 09:03:40
【问题描述】:
我使用客户端口(444)设置 docker 环境,因为那时我不想停止正常的 443 本地 Nginx。
这是我的 docker-composer.yml
version: '3.8'
services:
web:
container_name: custom_web
build:
context: ./
dockerfile: ./.docker/nginx/Dockerfile
volumes:
- ./src:/usr/share/nginx/html
- ./.docker/certs:/mycert
ports:
- "8080:80"
- "444:443"
.....
正常本地环境我尝试代理传到443到444。
server {
listen 80;
listen [::]:80;
server_name exmple.com;
return 302 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl http2;
listen [::]:443 ssl http2;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
root /var/www/html;
server_name exmple.com;;
location / {
proxy_pass http://127.0.0.1:444;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
但是在 nginx 服务器重新启动并运行后,我可以显示网络选项卡所有文件加载但显示错误
"400 Bad Request 纯HTTP请求被发送到HTTPS端口 nginx/1.19.2"
解决该错误的最佳方法是什么...
【问题讨论】:
标签: amazon-web-services nginx proxy docker-compose nginx-reverse-proxy