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

change request.URL in proxy #2109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

silverlyjoo
Copy link

@silverlyjoo silverlyjoo commented Mar 3, 2022

when I use this proxy middleware with target server that is also reverse proxy with nginx (k8s), it didn't work.
so I change request.URL to target.URL.Host

@aldas
Copy link
Contributor

aldas commented Mar 3, 2022

@silverlyjoo could you please add testcase for that.

@silverlyjoo
Copy link
Author

silverlyjoo commented Mar 3, 2022

Sorry, I think the explanation was lacking.

I'm using k8s and ingress config like this (example).

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: foo-bar-ingress-tls
spec:
  tls:
    - hosts:
        - foo-bar.net
      secretName: foo-bar-secret
  rules:
    - host: foo-bar.net
      http:
        paths:
          - path: /
            backend:
              serviceName: foo-bar-service
              servicePort: 80


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: bar-baz-ingress-tls
spec:
  tls:
    - hosts:
        - bar-baz.net
      secretName: bar-baz-secret
  rules:
    - host: bar-baz.net
      http:
        paths:
          - path: /
            backend:
              serviceName: bar-baz-service
              servicePort: 80


kind: Service
apiVersion: v1
metadata:
  name: ingress-node-vip
  namespace: ingress-nginx
spec:
  externalTrafficPolicy: Local
  selector:
    app.kubernetes.io/name:ingress-nginx
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: 80
  - name: https
    port: 443
    targetPort: 443

each ingress has it's own app (k8s deployment, service),
and I deploy this k8s cluster with service (ingress-node-vip).

so when i access with app with host : foo-bar.net and foo-bar-service is appear,
and access with app with host : bar-baz.net and bar-baz-service is appear.
(foo-bar.net and bar-baz.net each domain has same ip : ingress-node-vip service external ip)

there is a demand for bff app (for MSA), and i need to want to use this proxy middleware,
but for the request.Host, k8s ingress cannot classify my request and it comes 404 error.
(i think k8s ingress-nginx classify with request Host metadata.)

so I change this at my app with customProxy.go..
It doesn't matter if it's not accepted, but for just in case, I ask this.

sorry for my little English,
Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants