通过 https 访问服务器时出现 400 错误请求

通过 https 访问服务器时出现 400 错误请求

我使用 Portainer 运行 Atlassian Jira 实例。我希望能够通过 tpg.xyz/containerName(在本例中为 jira)访问每个容器。目前,我可以正常工作,但会抛出错误400 Bad Request - The plain HTTP request was sent to HTTP Port

当我输入 url 时会发生这种情况https://tpg.xyz/jira,然后它会更改为tpg.xyz:443/jira。如果我在 url 开头添加 https:// ,它会带我到 jira 的主页。但是,每次我导航到新页面时,https:// 都会从 url 中删除,并且我会遇到相同的错误 400。

知道我错过了什么吗?

编辑:意识到配置中有我的域,所以我也可以将它添加到问题中,以防有人可以提供帮助。

这是我的 Nginx 配置


server {
  server_name docker.tpg.xyz tpg.xyz www.tpg.xyz; # managed by Certbot

    location / {
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:9000;
        proxy_redirect off;
    }


    location /jira{
           proxy_pass            http://127.0.0.1:8081/jira;
           proxy_read_timeout    300;
          proxy_connect_timeout 300;
           proxy_redirect        off;
           proxy_set_header      X-Forwarded-Host $host;
           proxy_set_header      X-Forwarded-Server $host;
           proxy_set_header      X-Real-IP $remote_addr;
           proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;
 }

        listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server; # managed by Certbot
  #  listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/tpg.xyz/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/tpg.xyz/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = docker.tpg.xyz) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = www.tpg.xyz) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = tpg.xyz) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80 ;
    listen [::]:80 ;
    server_name docker.tpg.xyz tpg.xyz www.tpg.xyz;
    return 404; # managed by Certbot






}


答案1

事实证明,我错误地设置了一个环境变量,因为我最初在设置 jira 实例时并没有计划使用 https。我将环境变量 CATALINA_CONNECTOR_SCHEME 设置为 http。将其更改为 https 解决了该问题

相关内容