【问题标题】:Nginx Proxy Pass custom port to 443 to docker container(AWS,Ubuntu)Nginx 代理将自定义端口传递到 443 到 docker 容器(AWS,Ubuntu)
【发布时间】: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


    【解决方案1】:

    尝试将proxy_pass http://127.0.0.1:444;改为proxy_pass https://127.0.0.1:444;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-29
      • 1970-01-01
      • 2018-07-28
      • 2018-01-25
      • 1970-01-01
      • 1970-01-01
      • 2016-05-28
      • 2020-09-27
      相关资源
      最近更新 更多