400 Bad Request - The plain HTTP request was sent to HTTPS port #1547
Replies: 3 comments 21 replies
-
@ram-centime Hello there. From your You can try using To have NGINX Gateway fabric automatically do a redirect for HTTP requests to HTTPS, you will need to configure a redirect.
You can see our examples located in this repo and folder: Also, ensure your
Let us know if that helps. |
Beta Was this translation helpful? Give feedback.
-
One thing I'll note is that it appears you are using a BackendTLSPolicy, which is not yet supported. We are currently working on it (see #1487), which will be included in our next release. Current supported features of the Gateway API are included in our docs |
Beta Was this translation helpful? Give feedback.
-
@ram-centime Ok. After reviewing all the information you sent me. It looks to be that your upstream application server is expecting an HTTPS proxied connection from NGF to your application. I noticed you are using a A quick note, That being said, the See here: One last note. You will also have to make sure you are using the experimental APIs as well to test the let me know if I have your setup correct and if this is helpful. |
Beta Was this translation helpful? Give feedback.
-
Hi,
NGINX Gateway Fabric v1.0.0 installed in my EKS cluster version 1.28, when I access one of the service in my cluster giving 400 Bad Request - The plain HTTP request was sent to HTTPS port response when I access the service.
curl https://xxx.yyy.com/config-service/common/default/infra/currency-conversion.properties
<title>400 The plain HTTP request was sent to HTTPS port</title>400 Bad Request
The plain HTTP request was sent to HTTPS portnginx/1.25.3
Could you please help me in this regards.
I followed the below installation steps, also attaching the manifests.
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj '/CN=xxx.yyy.com' -addext 'subjectAltName=DNS:xxx.yyy.com'
kubectl create secret tls centimetls --key tls.key --cert tls.crt
openssl x509 -in tls.crt -out tls.pem -outform PEM
kubectl create configmap centimetls --namespace=func-services --from-file=tls.pem
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml
kubectl apply -f https://github.com/nginxinc/nginx-gateway-fabric/releases/download/v1.1.0/crds.yaml
kubectl apply -f https://github.com/nginxinc/nginx-gateway-fabric/releases/download/v1.1.0/nginx-gateway.yaml
loadbalancer-aws-nlb.yaml
Source: nginx-gateway-fabric/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-gateway
namespace: nginx-gateway
labels:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
app.kubernetes.io/version: "1.0.0"
annotations:
service.beta.kubernetes.io/aws-load-balancer-type: nlb
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-2::certificate/
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
service.beta.kubernetes.io/aws-load-balancer-ssl-negotiation-policy: ELBSecurityPolicy-TLS-1-2-2017-01
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: "true"
service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags: "owner=devops"
service.beta.kubernetes.io/aws-load-balancer-scheme: "internal"
spec:
externalTrafficPolicy: Local
type: LoadBalancer
selector:
app.kubernetes.io/name: nginx-gateway
app.kubernetes.io/instance: nginx-gateway
ports: # Update the following ports to match your Gateway Listener ports
port: 80
protocol: TCP
targetPort: 80
port: 443
protocol: TCP
targetPort: 443
gateway.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: func-services
namespace: func-services
spec:
gatewayClassName: nginx
listeners:
protocol: HTTP
port: 80
hostname: xxx.yyy.com
protocol: HTTPS
port: 443
hostname: xxx.yyy.com
tls:
certificateRefs:
group: ""
name: centimetls
route.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: config-service
namespace: func-services
spec:
parentRefs:
sectionName: https
hostnames:
rules:
port: 8443
matches:
type: PathPrefix
value: /config-service
tls.yaml
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: BackendTLSPolicy
metadata:
name: config-service
namespace: func-services
spec:
targetRef:
kind: Service
name: config-service
group: ""
tls:
caCertRefs:
- kind: ConfigMapReference
name: centimetls
group: ""
hostname: xxx.yyy.com
kubectl get svc config-service -n func-services -o yaml
apiVersion: v1
kind: Service
metadata:
annotations:
meta.helm.sh/release-name: config-service
meta.helm.sh/release-namespace: func-services
creationTimestamp: "2024-02-06T10:00:52Z"
labels:
app: config-service
app.kubernetes.io/managed-by: Helm
name: config-service
namespace: func-services
resourceVersion: "7727170"
uid: 68b26950-ba58-4b09-b714-725e00021318
spec:
clusterIP: 10.100.126.75
clusterIPs:
internalTrafficPolicy: Cluster
ipFamilies:
ipFamilyPolicy: SingleStack
ports:
port: 8443
protocol: TCP
targetPort: 8443
selector:
app: config-service
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
kubectl get deploy config-service -n func-services -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
meta.helm.sh/release-name: config-service
meta.helm.sh/release-namespace: func-services
creationTimestamp: "2024-02-06T10:00:52Z"
generation: 1
labels:
app: config-service
app.kubernetes.io/managed-by: Helm
name: config-service
namespace: func-services
resourceVersion: "8162390"
uid: 81f2680f-2497-4456-aa05-49fd4f64617c
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: config-service
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
annotations:
ad.datadoghq.com/config-service.logs: |-
[{
"source": "config-service",
"service": "config-service",
"log_processing_rules": [{
"type": "multi_line",
"name": "log_start_with_date",
"pattern" : "\d{4}-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])"
}]
}]
creationTimestamp: null
labels:
app: config-service
spec:
containers:
- env:
- name: server.servlet.context-path
value: /config-service
- name: spring.profiles.active
value: infra
- name: spring.cloud.config.uri
value: https://xxx.yyy.com/config-service
- name: spring.cloud.config.label
value: infra
- name: HOST_KAFKA
value: http://xxx.yyy.com:9092
- name: DEPLOY_ENV
value: infra
- name: JVM_MEM_OPTS
value: -Xms2048m -Xmx2048m
- name: LOG_LEVEL
value: INFO
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: CENTIME_DD_APM_ENABLED
value: "false"
- name: DD_VERSION
value: config-service-qa-16138
- name: DD_AGENT_HOST
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
- name: DD_ENV
value: infra
- name: DD_SERVICE
value: config-service
- name: DD_PROFILING_ENABLED
value: "false"
- name: DD_LOGS_INJECTION
value: "false"
- name: server.ssl.key-store
value: /usr/lib/jvm/java-certs/lib/security/centime-ssl.p12
- name: server.ssl.key-alias
value: centimessl
- name: server.ssl.key-store-password
value: centimessl
image: .dkr.ecr.us-east-2.amazonaws.com/config-service:qa-16138
imagePullPolicy: IfNotPresent
name: config-service
ports:
- containerPort: 8443
name: http
protocol: TCP
readinessProbe:
failureThreshold: 35
httpGet:
path: /config-service/actuator/health
port: 8443
scheme: HTTPS
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
resources:
limits:
cpu: 250m
memory: 1Gi
requests:
cpu: 200m
memory: 900Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /usr/lib/jvm/java-certs/lib/security
name: centimessl
readOnly: true
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: jfrogregcreds
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: centime-infra-common
serviceAccountName: centime-infra-common
terminationGracePeriodSeconds: 30
topologySpreadConstraints:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- config-service
maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- config-service
maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
volumes:
- name: centimessl
secret:
defaultMode: 420
secretName: centimessl
status:
availableReplicas: 1
conditions:
lastUpdateTime: "2024-02-06T10:02:16Z"
message: ReplicaSet "config-service-f6b44dc56" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
lastUpdateTime: "2024-02-07T05:19:09Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
observedGeneration: 1
readyReplicas: 1
replicas: 1
updatedReplicas: 1
Beta Was this translation helpful? Give feedback.
All reactions