emqx / emqx-auth-http

EMQX HTTP Authentication/ACL Plugin
https://emqx.io/
Apache License 2.0
43 stars 47 forks source link

Which ip did ipaddr get? #277

Open myifeng opened 2 years ago

myifeng commented 2 years ago
ipaddr=172.18.32.149

image

But 172.18.32.149 is not my ip address, why is this?

zmstone commented 2 years ago

hi. we need more context Where is this ip observed?

zmstone commented 2 years ago

If this is from the logs. Likely because emqx (old version?) tried to resolve configured host name fqdn to ip address

myifeng commented 2 years ago

I am using emqx in the k8s cluster,I see in my my-mqtt-auth logs that the ipaddr parameter is not as expected.

          name: emqx
          image: emqx/emqx:4.3.16
          ports:
            - name: mqtt
              containerPort: 1883
            - name: mqttssl
              containerPort: 8883
            - name: mgmt
              containerPort: 8081
            - name: ws
              containerPort: 8083
            - name: wss
              containerPort: 8084
            - name: dashboard
              containerPort: 18083
          env:
            - name: EMQX_NAME
              value: "emqx"
            - name: EMQX_CLUSTER__DISCOVERY
              value: "k8s"
            - name: EMQX_CLUSTER__K8S__APP_NAME
              value: "emqx"
            - name: EMQX_CLUSTER__K8S__SERVICE_NAME
              value: "emqx-headless"
            - name: EMQX_CLUSTER__K8S__ADDRESS_TYPE
              value: "hostname"
            - name: EMQX_CLUSTER__K8S__APISERVER
              value: "https://kubernetes.default.svc:443"
            - name: EMQX_CLUSTER__K8S__SUFFIX
              value: "svc.cluster.local"
            - name: EMQX_CLUSTER__K8S__NAMESPACE
              value: "default"
            - name: EMQX_LOADED_PLUGINS
              value: "emqx_recon,emqx_retainer,emqx_management,emqx_dashboard,emqx_auth_http"
            - name: EMQX_AUTH__HTTP__AUTH_REQ__URL
              value: "http://my-mqtt-auth:8080/auth/user"
            - name: EMQX_AUTH__HTTP__AUTH_REQ__METHOD
              value: "post"
            - name: EMQX_AUTH__HTTP__AUTH_REQ__HEADERS__CONTENT_TYPE
              value: "application/json"
            - name: EMQX_AUTH__HTTP__AUTH_REQ__PARAMS
              value: "username=%u,password=%P,clientId=%c,ipaddr=%a"       

ingress.yaml

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: emqx
  annotations:
    kubernetes.io/ingress.class: "nginx"
  namespace: default
spec:
  rules:
    - host: emqx.domain.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: emqx-service
                port:
                  number: 18083

ingress-tcp-udp-proxy.yaml

# tcp-data.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
data:
# <namespace/service name>:<service port>:[PROXY]:[PROXY]
  1883: "default/emqx-service:1883"
  8883: "default/emqx-service:8883"
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: udp-services
  namespace: ingress-nginx