R
RunPod•3w ago
Anan

accessing nginx server on my local machine

hello, can anyone help me access a server hosted on localhost:8000 on my pod from my pc's web browser. or can you provide a basic setup of nginx and how to access it on my local machine. i have gone through the documentation of exposing ports and it didn't work well
Solution:
Try to break it down into smaller problems: 1. HTTP server. 2. Connectivity. 3. Nginx config. ...
Jump to solution
12 Replies
nerdylive
nerdylive•3w ago
listen to 0.0.0.0 not localhost nor 127.0.0.1 *in the pod
hotsnr
hotsnr•3w ago
i did it recently and it worked fine. can you share more details?
nerdylive
nerdylive•3w ago
Me? Details about why it would work or from this thread owner
hotsnr
hotsnr•3w ago
No, I was asking thread owner. I normally don't use DIscord, got confused, sorry.
nerdylive
nerdylive•3w ago
Oh it's fine I'm just clarifying
Anan
AnanOP•3w ago
can you give me a basic config file for nginx and how to access it from my pc's web lets say its running on localhost:8000 in the pod inorder to access it from my pc's webrower i have to add the port to the tcp part right? so in connection window i will get the external port number for the port 8000 and add it with the ip of the pod? eg: 197.476.0.28:3579
nerdylive
nerdylive•3w ago
Http works
Solution
hotsnr
hotsnr•3w ago
Try to break it down into smaller problems: 1. HTTP server. 2. Connectivity. 3. Nginx config. 1) Try to use some very dumb HTTP server which doesn't need any configuration. For example, http-server from npm:
apt update
apt install -y npm
npm install -b http-server
http-server -a 0.0.0.0 -p 8000
apt update
apt install -y npm
npm install -b http-server
http-server -a 0.0.0.0 -p 8000
Note: you need to disable nginx first, otherwise http-server won't be able to start. Then open another SSH session and check that it works:
curl http://localhost:8000
curl http://localhost:8000
2) Next step - try to access it from the outside. First, make sure that port 8000 is exposed as TCP (not HTTP!) according to your template. When your pod is running, check out pod mappings - you need External port (8000 -> a.b.c.d:NNNN). Then you can try to open it in your browser - http://a.b.c.d:NNNN/. 3) Even the most basic config should work. Try this one, but don't forget to change port to 8000. https://ubuntu.com/server/docs/how-to-configure-nginx Note: don't forget to kill http-server before trying to launch nginx.
Anan
AnanOP•3w ago
tysm man this was really helpful 🥹
Anan
AnanOP•3w ago
i tried this and its working thank you. i have one doubt now that im running http server .. its getting connected to http server and not nginx right? so we can only connect to one server at a time? is the http server basically making the locahost:8000 port public? now if I go to ip:external in my browser it is showing my root directory and file in it. But I want to see the website i hosted in nginx (atleast the default nginx site)
hotsnr
hotsnr•2w ago
If you're running http-server then you're connecting to it, if you run nginx then you would connect to it. Did you do step 3? You need to run nginx in your container (and not http-server). You made it public by configuring it in the template. http-server is just something inside your container to respond on this port.
Anan
AnanOP•2w ago
whats the difference in running in container vs the other one I'm running
service nginx start
service nginx start
i didn't change the config file i just want to see it work after running the http server and connecting to it through the browser i can only access the files and directories, not a website. how do i go to a link and load a website instead of directories even if this starts working is it possible to send audio input from my pc to the pod. i saw somwhere it only shows a static website... (I'm new to all of this i just started)
Want results from more Discord servers?
Add your server