'Nginx-aws- Differenr url redirect to same server

we have example.com pointing to one instance and abc.example.com to another instance. we want example.com/abc should also point to abc.example.com instance. we don't want redirect , we want alias. How it can be possible ? Please Help.



Solution 1:[1]

Can you please use the ingress file as

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "abc-ingress"
  namespace: "ingress-nginx"
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
 
  labels:
    app: abc-app
spec:
  rules:
    - host: abc.example.com
      http:
        paths:
          - path: /abc
            backend:
              serviceName: abc-service
              servicePort: 80

again you have a new ingress file as

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "pqr-ingress"
  namespace: "ingress-nginx"
  annotations:
    kubernetes.io/ingress.class: alb
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
  labels:
    app: pqr-app
spec:
  rules:
    - host: pqr.example.com
      http:
        paths:
          - path: /pqr
            backend:
              serviceName: pqr-service
              servicePort: 80

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Balasaheb Karjule