Accessing nginx ingress controller on port 80

12/25/2018

I am able to access the nginx ingress controller on the NodePort. My goal is to access the controller on port 80.

Output of kubectl -n ingress-nginx describe service/ingress-nginx

Name:                     ingress-nginx
Namespace:                ingress-nginx
Labels:                   app.kubernetes.io/name=ingress-nginx
                          app.kubernetes.io/part-of=ingress-nginx
Annotations:              kubectl.kubernetes.io/last-applied-configuration:
                            {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/name":"ingress-nginx","app.kubernetes.io/par...
Selector:                 app.kubernetes.io/name=ingress-nginx,app.kubernetes.io/part-of=ingress-nginx
Type:                     NodePort
IP:                       10.100.48.223
Port:                     http  80/TCP
TargetPort:               80/TCP
NodePort:                 http  30734/TCP
Endpoints:                192.168.0.8:80
Port:                     https  443/TCP
TargetPort:               443/TCP
NodePort:                 https  32609/TCP
Endpoints:                192.168.0.8:443
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

I have few ideas of solving that problem:

  • redirect traffinc incoming on port 30734 to port 80 via iptables
  • resize the range for nodeports so port 80 can be a nodeport as well

I am not sure if these are common ways to do this, so I'd love to hear how you usually deal with this. Probably there is another component necessary?

-- elp
kubernetes
nginx-ingress

2 Answers

12/25/2018

The normal way to handle this is with a LoadBalancer mode service which puts a cloud load balancer in front of the existing NodePort so that you can remap the normal ports back onto it.

-- coderanger
Source: StackOverflow

12/26/2018

You should change from NodePort to LoadBalancer type for your nginx service. Example manifest look like:

spec:
  ports:
  - name: nginx
    port: 80
    protocol: TCP
    targetPort: 8000 // Your nginx port
  type: LoadBalancer
-- WorkWe
Source: StackOverflow