The following is the .yaml used to create the Ingress:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test
annotations:
kubernetes.io/ingress.class: "nginx"
ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- host: foo.com
http:
paths:
- path: /foo
backend:
serviceName: http-svc
servicePort: 80
The following is the Deployment and the ConfigMap of the controller, almost the same as file in examples/deployment/nginx/nginx-ingress-controller.yaml except the last line.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-ingress-config
namespace: kube-system
data:
ssl-redirect: "false"
hsts: "false"
disable-ipv6: "true"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller
labels:
k8s-app: nginx-ingress-controller
namespace: kube-system
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: nginx-ingress-controller
annotations:
prometheus.io/port: '10254'
prometheus.io/scrape: 'true'
spec:
# hostNetwork makes it possible to use ipv6 and to preserve the source IP correctly regardless of docker configuration
# however, it is not a hard dependency of the nginx-ingress-controller itself and it may cause issues if port 10254 already is taken on the host
# that said, since hostPort is broken on CNI (https://github.com/kubernetes/kubernetes/issues/31307) we have to use hostNetwork where CNI is used
# like with kubeadm
# hostNetwork: true
terminationGracePeriodSeconds: 60
containers:
- image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.5
name: nginx-ingress-controller
readinessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
livenessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
timeoutSeconds: 1
ports:
- containerPort: 80
hostPort: 80
- containerPort: 443
hostPort: 443
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend
- --configmap=$(POD_NAMESPACE)/nginx-ingress-config
A simple 404 test, the result is as expected:
$ curl -H "Host: foo.com" http://x.x.x.x/f
default backend - 404
however, testing the ingress gives an HTTPS redirect, instead of the response from "http-svc"
$ curl -H "Host: foo.com" http://x.x.x.x/foo
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.9.11</center>
</body>
</html>
I don't want HTTPS, because my services are running in a trusted environment, and managing all those certificates/keys are too much trouble for me.
@torshie the redirect is being returned by the service http-svc not the ingress controller (the nginx version of the controller is 1.11.13).
Please reopen if you have any other question
opened issue https://github.com/kubernetes/ingress-nginx/issues/1565.
Looks like this is caused by not setting the host
What host and where? Which Kubernetes Resource. Please be specific.
This really needs to be reopened and answered. I鈥檓 getting the same problem and this is he first hit on google.
On the Ingress, see below minikube is specified as a host so that you can use http
apiVersion: extensions/v1beta1
kind: Ingress
....
spec:
rules:
Most helpful comment
This really needs to be reopened and answered. I鈥檓 getting the same problem and this is he first hit on google.