Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need to configure my router so I can access the website I have running on my computer from the outside world.

How can I do this? I think I need to open the port 80 on the router, which gets forwarded to a specific ip address i.e. 192.168.1.200.

Then somehow tell ubuntu to send any traffic coming through port 80 to /var/www

My router is a Linksys BEFSR41.

share|improve this question
2  
To clarify, the common theme in the answers is that Ubuntu hasn't got anything to do with port forwarding (unless it is, in fact, the router..). If Apache is set up for port 80, your ubuntu isn't blocking port 80, and your router is actually port forwarding, then it works. If not, one of those things is broken. –  djeikyb Apr 3 '11 at 6:55

4 Answers 4

up vote 2 down vote accepted

Port 80 is the standard HTTP port, so you just have to install a web server (eg. apache2) on your Ubuntu machine. When it comes to the router, you just have to forward port 80 on the router to port 80 on your Ubuntu machine. How to do that depends on the router, but it should be configurable from the web interface.

share|improve this answer
    
I have port 80 forwarded and have set it to 192.168.1.200, how do i tell ubuntu to forward any traffic going to 192.168.1.200 to the localhost website? as I already have lamp setup. –  oshirowanen Apr 2 '11 at 9:39
    
You don't have to forward anything on Ubuntu, the web server should listen directly on port 80. You can verify that using netstat -tlp. –  Adam Byrtek Apr 2 '11 at 9:49
    
It doesn't work. When I type in my IP address into the browser, I get a page not found error. –  oshirowanen Apr 2 '11 at 16:04
    
@oshirowanen Be clearer. From another computer on your lan, can you access the website at the local ip address? If the answer is no, then 1) could be firewall. run ufw disable to test 2) if not 1, then apache is not setup right. YOU MUST get the local network working first. –  djeikyb Apr 3 '11 at 7:44
    
@oshirowanen You have to make it work locally before you even start to play with port forwarding. Is your web server running and configured correctly? Does netstat -tlp show the port as open? –  Adam Byrtek Apr 3 '11 at 9:57

There's only one resource you'll ever need:

share|improve this answer
    
I have port 80 forwarded and have set it to 192.168.1.200, how do i tell ubuntu to forward any traffic going to 192.168.1.200 to the localhost website? as I already have lamp setup. –  oshirowanen Apr 2 '11 at 9:40
    
Here portforward.com/english/routers/port_forwarding/Linksys/BEFSR41/… are the instructions you need to do the port-forwarding (as that was your question). On your Ubuntu machine (which I hope has IP 192.168.1.200) you don't have to do anything, other than start Apache. –  bitwelder Apr 2 '11 at 11:50
    
How do I find out if my machine has 192.168.1.200? If it doesn't how do I set it up, or which IP address should I be using as 192.168.1.1 goes to my router. –  oshirowanen Apr 2 '11 at 16:05
1  
@oshirowanen: in the terminal, do ifconfig -a. Find whichever is the correct internet interface (it should be eth0 or wlan0 or similar). That can tell you specifically what assigned IPs are given to the system. If you include a pastebin of ifconfig -a's output, we can help you find the specific IP among other details that are relevant. –  Thomas W. Apr 2 '11 at 19:55
    
this is the best site in the whole world. Thank you Oli! :D –  Alvar Mar 31 '12 at 10:59

These are couple of things you need to do to accomplish this, that is after you make your web server working.

  1. Know your ISP IP address. You can see this by going to whatismyip.com
  2. If you own a domain and an hosting account that lets you do a Simple DNS Zone Editor modification (CPanel Hosting normally have this)
  3. Add an A record and enter your ISP's IP in the address field
  4. Then in your router you just need to specify you Computers IP address and port 80
  5. You also need to put ServerName your.domain.com in your apache configuration file

That's it.. You can even do virtual hosting on 1 machine :) My only bad experience about this is that some ISP's don't allow me to have this setup. I tried it in 3 diff ISP's now and it only worked in 1 of them.

share|improve this answer

You need to do 3 things some of which you might have already done.

  1. Install apache or some other web server
  2. Forward Port 80 through your router to the IP of the machine running the web server
  3. Set up some way that you can know what your public IP of your router is at all times so you can access your server from the web.

As a side note /var/www is the usually the default root for a web server on linux

share|improve this answer
    
I have port 80 forwarded and have set it to 192.168.1.200, how do i tell ubuntu to forward any traffic going to 192.168.1.200 to the localhost website? as I already have lamp setup. –  oshirowanen Apr 2 '11 at 9:39
    
@oshirowanen If you have the webserver running it should snatch any access to port 80. To test this just use any other computer on your network and type the IP of the machine running the server into the web browser (or use 127.0.0.1 on the machine using the web server) –  Reuben Swartz Apr 2 '11 at 23:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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