<p>i am new to kubernetes(minikube). I have an application with frotnend(vue cli) and backend(python, node js). On the frontend i am using nginx to serve the vue build version. My nginx config is like this.</p>
<pre><code>user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
  worker_connections  1024;
}
http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;
  log_format  main  '$remote_addr - $remote_user [$time_local] &quot;$request&quot; '
                    '$status $body_bytes_sent &quot;$http_referer&quot; '
                    '&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;';
  access_log  /var/log/nginx/access.log  main;
  sendfile        on;
  keepalive_timeout  65;
  server {
    listen       80;
    location / {
      root   /frontend;
      index  index.html;
      try_files $uri $uri/ /index.html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   /usr/share/nginx/html;
    }
  }
}
</code></pre>
<p>in my vue.config.js i have configuration that is redirecting to the backend which having 4 node js server listening to ports 3001,3002,3003,3004.
My vue.config.js file</p>
<pre><code>module.exports = {
  publicPath: &quot;/&quot;,
  devServer: {
    proxy: {
      &quot;^/api/server/v1&quot;: {
        target: &quot;http://localhost:3000&quot;,
        logLevel: &quot;debug&quot;,
        changeOrigin: true,
        pathRewrite: { &quot;^/api/server/v1&quot;: &quot;/api/server&quot; },
      },
      &quot;^/mongo-api&quot;: {
        target: &quot;http://localhost:5001&quot;,
        logLevel: &quot;debug&quot;,
        changeOrigin: true,
        pathRewrite: {
          &quot;^/mongo-api&quot;: &quot;&quot;,
        },
      },
      &quot;^/mongo-stream&quot;: {
        target: &quot;http://localhost:3004&quot;,
        logLevel: &quot;debug&quot;,
        changeOrigin: true,
        pathRewrite: {
          &quot;^/mongo-stream&quot;: &quot;&quot;,
        },
      },
      &quot;^/rest-api&quot;: {
        target: &quot;http://localhost:5002&quot;,
        logLevel: &quot;debug&quot;,
        changeOrigin: true,
        pathRewrite: {
          &quot;^/rest-api&quot;: &quot;&quot;,
        },
      },
      &quot;^/api&quot;: {
        target: &quot;https://api.binance.com&quot;,
        logLevel: &quot;debug&quot;,
      },
    },
  },
}

</code></pre>
<p>Now my question is that how can i make request to the backend from frontend. I have already configured the deployment and services for this and it is using Clusterip on the backend pods and nodeip on the frontend service.
i was using localhost for all my communication in case of running with docer-compose.yaml.
My backend-server-service.yaml is like this</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert --build=local -v
    kompose.service.type: clusterip
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: backend-server
  name: backend-server
spec:
  ports:
  - name: &quot;3000&quot;
    port: 3000
    targetPort: 3000
  - name: &quot;3001&quot;
    port: 3001
    targetPort: 3001
  - name: &quot;3002&quot;
    port: 3002
    targetPort: 3002
  selector:
    io.kompose.service: backend-server
  type: ClusterIP
status:
  loadBalancer: {}

</code></pre>
<p>I am using Kompose command to generate deployments and services.<strong>Now how can i configure the nginx like when i make request to localht:3000 or localhost:3001 then it will redirect to my container inside pod and which is inside a cluster</strong></p>

Binoy Sarker
<p>If both the frontend and the backend are running in the same namespace, it should be as simple as replacing <code>http://localhost:3000</code> with <code>http://backend-server:3000</code>, where <code>backend-server</code> is the name of the backend server <code>Service</code>.</p>
