Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirection issue #1106

Closed
saivikas408 opened this issue Aug 21, 2020 · 3 comments
Closed

Redirection issue #1106

saivikas408 opened this issue Aug 21, 2020 · 3 comments

Comments

@saivikas408
Copy link

saivikas408 commented Aug 21, 2020

Hi All,

I have redirection issue from http to https , I am struck with this from 3 days

Here are my kubernetes yaml files

# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
---
# service.yaml
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
---
# master-ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: nginx-ingress-master
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.org/mergeable-ingress-type: "master"
    nginx.org/redirect-to-https: "True"
spec:
  rules:
  - host: myexample.com
---
# minion-ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: sample-web-ingress-minion
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.org/mergeable-ingress-type: "minion"
    nginx.org/rewrites: "serviceName=my-service rewrite=/"
spec:
  rules:
  - host: myexample.com
    http:
      paths:
      - path: /myapp
        backend:
          serviceName: my-service
          servicePort: 80
---

And also here is my nginx service

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress
  namespace: nginx-ingress
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: "*"
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn:aws:acm:us-west-1:xxxxxxxxxxxxx:certificate/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx"
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http
  - port: 443
    targetPort: 80
    protocol: TCP
    name: https
  selector:
    app: nginx-ingress

when I use above files I am able to get the output as below ,but redirection is not happening
when i hit http://myexample.com/myapp --> Shows nginx homepage
when i hit https://myexample.com/myapp --> Shows nginx homepage

Expected behavior

when i hit http://myexample.com/myapp it should redirect to https://myexample.com/myapp and it should display nginx homepage

Your environment

  • Version of the Ingress Controller - release version or a specific commit : Version=1.7.2 GitCommit=ad92aa9d
  • Version of Kubernetes : 1.18.5
  • Kubernetes platform (e.g. Mini-kube or GCP) : AWS
  • Using NGINX or NGINX Plus : NGINX

Is there any documentation on how to use Amazon ACM certificates with nginx ?

@saivikas408
Copy link
Author

saivikas408 commented Aug 21, 2020

update : After seeing some other issues resolution i have added below annotation to ngnix service file

service.beta.kubernetes.io/aws-load-balancer-backend-protocol: "http"

when i hit http://myexample.com/myapp --> HTTP ERROR 503 - This page isn’t working
when i hit https://myexample.com/myapp --> HTTP ERROR 503 -This page isn’t working

error in logs :

" while reading PROXY protocol, client: 10.55.177.12, server: 0.0.0.0:80
2020/08/21 15:16:31 [error] 35#35: 29 broken header: "GET / HTTP/1.1
host: myexample.com
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,
/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en-IN,en;q=0.9
Cache-Control: max-age=0
Cookie: _xsrf=2|4dc5e183|7e7ea118etyucd4c5de9a2ac366118|1596635696
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36
X-Forwarded-For: 201.241.55.21
X-Forwarded-Port: 80
X-Forwarded-Proto: http
Connection: keep-alive

Please help , if I am missing something !!

@pleshakov
Copy link
Contributor

Hi @saivikas408

Please take a look at the solution in this issue #548
also, it seems that you enabled proxy protocol in the ConfigMap. If you use http protocol between ELB and NGINX, then there is no need to configure proxy protocol.

@saivikas408
Copy link
Author

Thanks @pleshakov ,

After removing proxy protocol from ConfigMap , redirection is working !!

Thanks Much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants