问题描述
我在docker环境中设置了客户端口(444),因为那样我不想停止正常的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服务器重启并运行后,我可以显示“网络”选项卡上的所有文件加载,但显示错误
解决方法
尝试将proxy_pass http://127.0.0.1:444;
更改为proxy_pass https://127.0.0.1:444;