0

I know this is a super basic question but I've read about 100 webpages and tutorials and haven't been able to figure things out.

So, I've bought a domain name and connected to my external ip address. The problem is, that just directs to my dd-wrt router home page. Not super helpful. I have nginx set up on my ubuntu machine and that serves things locally just fine. I have added to /etc/hosts the following

192.0.2.37 mywebsite.example
192.0.2.37 www.mywebsite.example

where 192.0.2.37 is my external IP address.

How do I convince my router to let the connection through for my computer to serve?

Edit

The answers below are both helpful but I should have mentioned that I had already set up port forwarding. Perhaps this is a problem with where I bought my domain and have not yet set that up properly? It does point to my external ip but doesn't appear to be making any requests from a particular address/host within the network

  • Can you see your website when you type the external IP address in the browser? If so, port forwarding is set up correctly and it is a matter of setting up the domain DNS. If not, then you didn't set up port forwarding correctly. – Stephen Ostermiller Jul 8 '19 at 12:38
  • So on my computer which is running nginx then yes, entering my external ip does direct me to my wesbite. Not from an external device (my phone for example) though. – Aaron Zolotor Jul 8 '19 at 15:39
  • You have to test it from external devices like your phone. Port forwarding is not working correctly. It is possible that your ISP is blocking port 80. In that case you will need to run your web server on a different port like port 8080, port forward that, and use that port number in your URLs. – Stephen Ostermiller Jul 8 '19 at 17:22
  • Sorry, what do you mean by use that port number in your URLs? – Aaron Zolotor Jul 8 '19 at 17:28
  • Like http://example.com:8080/index.html – Stephen Ostermiller Jul 8 '19 at 18:30
1

You are looking for the feature of your router called Port Forwarding. Port forwarding directs the router to pass calls at a specific port number through to an internal server to be serviced.

For a website, you will want to set up port forwarding for port 80 (HTTP) and port 443 (HTTPS). Forward those two ports from your router to the IP address of your computer. Then your website will be available externally.

The DD-WRT Wiki has specific instructions for setting up port forwarding. I've never encountered a router that didn't support the feature, but the interface for setting it up is a little different on every brand of router.

If you have correctly configured the domain name DNS entries, you shouldn't need any entries in your /etc/hosts file. It looks like what you put there is just duplicating what the DNS should already have. If anything, you could configure your router's DNS server to serve the internal IP address of your computer to local machines for the domain name so that they can get to the site more directly. There is no need for the requests to be routed outside your internal network.

| improve this answer | |
1

Yes @stephen is right.. You need to do port forwarding in your router to route the incoming call to your particular pc on the network.. But i would like to add onething here is, that some router dynamically assign internal IP addresses to clients (connected pcs) which might end up the call ending no where or on the wrong pc. (like one day ur laptop will have op 192.168.1.111 and next day when u switch on router it might assign 192.168.1.112 to the same client. Now most of the routers gives you option to preset assignment of static internal IP based on its mac address. Which will help router to identify the client by its mac address and always assign your saved internal IP to that particular pc (ex: 192.168.1.111). And some routers even have option of setting up different incoming/outgoing ports alongwith ip assignments for forwarding. for example u can forward call to port 80 on external ip 100.100.100.10:80 ending on 192.168.1.111:8000. So please keep these things in mind while setting up the port forwarding on any router

| improve this answer | |
1

If you can access your website from an external device then port forwarding and dns is all okay. If u can NOT access it from WITHIN your network it could be your router doesn't support NAT loopback.

| improve this answer | |
1

The problem was that the routers homepage was listening on the same port as my webserver. Once I changed where my router was listening for it's admin page all was well.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.