Goglides Dev 🌱

Goglides Dev 🌱 is a community of amazing users

We are working on this space so that IT professionals can grow together.

Create account Log in
Balkrishna Pandey
Balkrishna Pandey

Posted on

How to forward ports to see the Nginx server page using the browser?

Let's port forward to the Nginx pod created by the deployment we created in the previous step. To do this, we'll use Kubectl to forward traffic from our local machine (the host) to the Nginx pod.


kubectl port-forward deployment/nginx 8080:80 

Enter fullscreen mode Exit fullscreen mode

Output:


Forwarding from 127.0.0.1:8080 -> 80

Forwarding from [::1]:8080 -> 80

Handling connection for 8080

Enter fullscreen mode Exit fullscreen mode

To verify open different terminals and run the following command,


curl localhost:8080

Enter fullscreen mode Exit fullscreen mode

Output:


<!DOCTYPE html>

<html>

<head>

<title>Welcome to nginx!</title>

<style>

html { color-scheme: light dark; }

body { width: 35em; margin: 0 auto;

font-family: Tahoma, Verdana, Arial, sans-serif; }

</style>

</head>

<body>

<h1>Welcome to nginx!</h1>

<p>If you see this page, the nginx web server is successfully installed and

working. Further configuration is required.</p>



<p>For online documentation and support please refer to

<a href="http://nginx.org/">nginx.org</a>.<br/>

Commercial support is available at

<a href="http://nginx.com/">nginx.com</a>.</p>



<p><em>Thank you for using nginx.</em></p>

</body>

</html>

Enter fullscreen mode Exit fullscreen mode

You can also use web browser and type, http://localhost:8080 to see the nginx server page.

Now that we have seen how to port forward ports from deployments and run commands inside containers, let's look at some more advanced deployment operations.

Discussion (0)