Unable to access nginx deployment in kubernetes (minikube)

I am trying to deploy a application with two pods (django and nginx)

how do i access the website on nginx container,

I am trying to access it on

  1. minikbe-ip:30007
  2. kubectl port-forward service/my-service 30007:80 => http://192.168.49.2:30007/

when i access it from 127.0.0.1:30007
I get error

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>403 Forbidden
nginx/1.19.0
</code>
<code>403 Forbidden nginx/1.19.0 </code>
403 Forbidden
nginx/1.19.0

this is default.conf file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>upstream backend {
server backend:8000;
}
server {
listen 80;
location /api/ {
proxy_pass http://backend;
}
location /static/rest_framework/ {
root /static/;
}
location / {
root /var/www/frontend;
try_files $uri $uri/ /index.html;
}
}
</code>
<code>upstream backend { server backend:8000; } server { listen 80; location /api/ { proxy_pass http://backend; } location /static/rest_framework/ { root /static/; } location / { root /var/www/frontend; try_files $uri $uri/ /index.html; } } </code>
upstream backend {
    server backend:8000;
}

server {
    listen 80;

    location /api/ {
        proxy_pass http://backend;
    }

    location /static/rest_framework/ {
        root /static/;
    }

    location / {
        root /var/www/frontend;
        try_files $uri $uri/ /index.html;
    }
}

These are service information

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>C:UsersDell>kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 41d v1.28.3
C:UsersDell>minikube ip
192.168.49.2
C:UsersDell>kubectl get all
NAME READY STATUS RESTARTS AGE
pod/django-app-965fd6c5b-45clx 1/1 Running 1 4h54m
pod/nginx-app-557dcd558c-gbdjh 1/1 Running 0 20m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/django-service ClusterIP 10.110.164.131 <none> 8000/TCP 14h
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 13d
service/my-service NodePort 10.111.8.176 <none> 80:30007/TCP 14h
service/nginx-service ClusterIP 10.103.234.114 <none> 80/TCP 14h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/django-app 1/1 1 1 4h54m
deployment.apps/nginx-app 1/1 1 1 20m
NAME DESIRED CURRENT READY AGE
replicaset.apps/django-app-965fd6c5b 1 1 1 4h54m
replicaset.apps/nginx-app-557dcd558c 1 1 1 20m
C:UsersDell>kubectl get pods
NAME READY STATUS RESTARTS AGE
django-app-965fd6c5b-45clx 1/1 Running 1 4h55m
nginx-app-557dcd558c-gbdjh 1/1 Running 0 20m
</code>
<code>C:UsersDell>kubectl get nodes NAME STATUS ROLES AGE VERSION minikube Ready control-plane 41d v1.28.3 C:UsersDell>minikube ip 192.168.49.2 C:UsersDell>kubectl get all NAME READY STATUS RESTARTS AGE pod/django-app-965fd6c5b-45clx 1/1 Running 1 4h54m pod/nginx-app-557dcd558c-gbdjh 1/1 Running 0 20m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/django-service ClusterIP 10.110.164.131 <none> 8000/TCP 14h service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 13d service/my-service NodePort 10.111.8.176 <none> 80:30007/TCP 14h service/nginx-service ClusterIP 10.103.234.114 <none> 80/TCP 14h NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/django-app 1/1 1 1 4h54m deployment.apps/nginx-app 1/1 1 1 20m NAME DESIRED CURRENT READY AGE replicaset.apps/django-app-965fd6c5b 1 1 1 4h54m replicaset.apps/nginx-app-557dcd558c 1 1 1 20m C:UsersDell>kubectl get pods NAME READY STATUS RESTARTS AGE django-app-965fd6c5b-45clx 1/1 Running 1 4h55m nginx-app-557dcd558c-gbdjh 1/1 Running 0 20m </code>
C:UsersDell>kubectl get nodes
NAME       STATUS   ROLES           AGE   VERSION
minikube   Ready    control-plane   41d   v1.28.3

C:UsersDell>minikube ip
192.168.49.2

C:UsersDell>kubectl get all
NAME                             READY   STATUS    RESTARTS   AGE
pod/django-app-965fd6c5b-45clx   1/1     Running   1          4h54m
pod/nginx-app-557dcd558c-gbdjh   1/1     Running   0          20m

NAME                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
service/django-service   ClusterIP   10.110.164.131   <none>        8000/TCP       14h
service/kubernetes       ClusterIP   10.96.0.1        <none>        443/TCP        13d
service/my-service       NodePort    10.111.8.176     <none>        80:30007/TCP   14h
service/nginx-service    ClusterIP   10.103.234.114   <none>        80/TCP         14h

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/django-app   1/1     1            1           4h54m
deployment.apps/nginx-app    1/1     1            1           20m

NAME                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/django-app-965fd6c5b   1         1         1       4h54m
replicaset.apps/nginx-app-557dcd558c   1         1         1       20m

C:UsersDell>kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
django-app-965fd6c5b-45clx   1/1     Running   1          4h55m
nginx-app-557dcd558c-gbdjh   1/1     Running   0          20m

here are deployment files

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>and here are service informations
# Django Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: django-app
spec:
replicas: 1
selector:
matchLabels:
app: django-app
template:
metadata:
labels:
app: django-app
spec:
containers:
- name: django-container
image: ash414/e-cart-backend:v1.0
imagePullPolicy: Never
ports:
- containerPort: 8000
# Django Service
apiVersion: v1
kind: Service
metadata:
name: django-service
labels:
app: django-app
spec:
selector:
app: django-app
ports:
- protocol: TCP
port: 8000
targetPort: 8000
# Nginx Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-app
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx-app
template:
metadata:
labels:
app: nginx-app
spec:
containers:
- name: nginx-container
# image: e-cart-nginx:latest
# image: ash414/e-cart-nginx:v1.0v
image: ash414/e-cart-nginx-dj4:v1.0
ports:
- containerPort: 80
# Nginx Service
apiVersion: v1
kind: Service
metadata:
name: nginx-service
labels:
app: nginx
spec:
selector:
app: nginx-app
ports:
- protocol: TCP
port: 80
targetPort: 80
# NodePort Service
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort
selector:
app: nginx-app
ports:
- port: 80
targetPort: 80
nodePort: 30007
</code>
<code>and here are service informations # Django Deployment apiVersion: apps/v1 kind: Deployment metadata: name: django-app spec: replicas: 1 selector: matchLabels: app: django-app template: metadata: labels: app: django-app spec: containers: - name: django-container image: ash414/e-cart-backend:v1.0 imagePullPolicy: Never ports: - containerPort: 8000 # Django Service apiVersion: v1 kind: Service metadata: name: django-service labels: app: django-app spec: selector: app: django-app ports: - protocol: TCP port: 8000 targetPort: 8000 # Nginx Deployment apiVersion: apps/v1 kind: Deployment metadata: name: nginx-app labels: app: nginx spec: replicas: 1 selector: matchLabels: app: nginx-app template: metadata: labels: app: nginx-app spec: containers: - name: nginx-container # image: e-cart-nginx:latest # image: ash414/e-cart-nginx:v1.0v image: ash414/e-cart-nginx-dj4:v1.0 ports: - containerPort: 80 # Nginx Service apiVersion: v1 kind: Service metadata: name: nginx-service labels: app: nginx spec: selector: app: nginx-app ports: - protocol: TCP port: 80 targetPort: 80 # NodePort Service apiVersion: v1 kind: Service metadata: name: my-service spec: type: NodePort selector: app: nginx-app ports: - port: 80 targetPort: 80 nodePort: 30007 </code>
and here are service informations
# Django Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: django-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: django-app
  template:
    metadata:
      labels:
        app: django-app
    spec:
      containers:
      - name: django-container
        image: ash414/e-cart-backend:v1.0
        imagePullPolicy: Never 
        ports:
        - containerPort: 8000

# Django Service
apiVersion: v1
kind: Service
metadata:
  name: django-service
  labels:
    app: django-app
spec:
  selector:
    app: django-app
  ports:
    - protocol: TCP
      port: 8000
      targetPort: 8000

# Nginx Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-app
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx-app
  template:
    metadata:
      labels:
        app: nginx-app
    spec:
      containers:
      - name: nginx-container
        # image: e-cart-nginx:latest
        # image: ash414/e-cart-nginx:v1.0v
        image: ash414/e-cart-nginx-dj4:v1.0
        ports:
        - containerPort: 80

# Nginx Service
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    app: nginx
spec:
  selector:
    app: nginx-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

# NodePort Service
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: nginx-app
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30007

I trying to access my website on nginx deployment with localhost:port-no

New contributor

Ash C is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật