eu tenho um aplicativo que está exposto em http na porta http://app1.internal.example.com:8080
e https na portahttps://app1.internal.example.com:8443
então eu tenho o bloco de servidor nginx 80 e 443 para ajudar a redirecionar a solicitação que vem da porta http para a porta https do aplicativo
$ curl http://app1.internal.example.com:8080
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
</body>
</html>
$ curl -IL http://app1.internal.example.com:8080
HTTP/1.1 400 Bad Request
Date: Wed, 09 Nov 2022 00:39:30 GMT
Content-Type: text/html
Content-Length: 220
Connection: close
e aqui está curl na porta https que retorna 200
$ curl -IL https://app1.internal.example.com:8443
HTTP/1.1 200 OK
Date: Wed, 09 Nov 2022 00:38:00 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1274335
Connection: keep-alive
Keep-Alive: timeout=20
Vary: Accept-Encoding
abaixo está o meu bloco de servidor nginx para o redirecionamento http para https
como corrijo esse erro para que o curl possa retornar 200 na solicitação http
server {
listen 80;
listen [::]:80;
server_name app1.internal.example.com;
return 301 https://app1.internal.example.com:8443$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name app1.internal.example.com;
location ^~ / {
proxy_pass http://localhost:5000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}