echo icon indicating copy to clipboard operation
echo copied to clipboard

change request.URL in proxy

Open silverlyjoo opened this issue 2 years ago • 2 comments

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

silverlyjoo avatar Mar 03 '22 10:03 silverlyjoo

@silverlyjoo could you please add testcase for that.

aldas avatar Mar 03 '22 10:03 aldas

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!

silverlyjoo avatar Mar 03 '22 11:03 silverlyjoo