anitsh / ama

Ask Anit Anything
https://codeanit.com
MIT License
1 stars 0 forks source link

Redirect incoming and outgoing traffic in router #2

Open amrit073 opened 1 year ago

amrit073 commented 1 year ago

I am trying to run server in my router and use custom domain using cloudflared. I have compiled cloudflared for router's architecture (mips) and installed it. But shell in not allowing cloudflared to make https request to its servers.

anitsh commented 1 year ago

Hi @amrit073,

Were you really able to install server on your router?

I think what you might have done is run a server in your local machine, laptop.

You have to have static IP or public IP to share your system/API in public.

Then in your router you have to open and map the port. Open port to allow requests from outside is allowed. Then map the same port to your local machine's and it IP.

For example, you have opened port 80 in your router. And your are running an application in port 8080. Then you map routers 80 port to machine running application with IP 192.168.1.100 port 8080.

In other words, redirect incoming and outgoing traffic to and from 80 > 192.168.1.100:8080.

On ca-certs, https://letsencrypt.org would be best. For reference, https://github.com/anitsh/til/issues/60 - My attempt and learning from hosting website from home setup.

Also, please delete the first empty comment. [I've done that on your behalf] Make title more short and specific. [I've done that on your behalf] Add more details on your question.

Helps everyone to understand and be of more help to you.

Cheers,

amrit073 commented 1 year ago

@anitsh I am used nc to listen to a port and served html page to incoming request. My server.sh file: while true; do echo -e "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" | cat - index.html | nc -l -p 8000; done I was able to access website in via my other devices from :8000. I tried cloudflared to add my custom domain but that will need router shell to make https requests.

anitsh commented 1 year ago

@amrit073 The default port is 80 for HTTP request. May be you can try with -p 80. But still serving HTTP requests via nc might not be very useful if we are looking forward to build a useful system.