how to set up an http server from scratch

1

I am an almost absolute beginner to the world of servers. I have no knowledge of setting up a server aside from running apachectl -k start and seeing "it works!" in localhost. I've tried dabbling in "port forwarding" and tried to get something to work in no-ip.com, but after a while I had no idea what I was doing. If it means anything, the process I tried through no ip was:

  • port forwarding the http port on my laptop through my router (this is how it looks
  • running apache
  • running the noip client
  • creating a host on noip (with settings DNS Host(A), and whatever IP address it detected)
  • accessing the domain created by no-ip.

What ended up happening was when I tried accessing the domain (which by the way is swarajd.no-ip.org), it times out. I recognize that I am doing something wrong but I do not know what to do in order to remedy the mistake.

I want to be able to set up a simple web server on my laptop running openSUSE, through my verizon actiontec MI424WR router, on a simple domain name such as swarage.somewebsite.info or something.

(note: this question is cross-posted from stack overflow, as a moderator from there recommended this question be asked here).

Swarage

Posted 2013-12-31T01:05:38.937

Reputation: 111

Answers

0

These are the steps you should follow to get a server up and running:

First get apache up and running and figure out where to put the html files. (You seem to have this already). On ubuntu after installing apache, the index.html should be in /var/www (it might be simillar for SUSE).

After typing POTATO in index.html, you should be able to write localhost in your webbrowser and it should show POTATO. It works? Then your server is already running!

Now if you grab another computer in the same network, you should be able to type your laptop's IP in the web-browser and see POTATO.

You can look-up your computer's IP fiddling around in connection information (I have no clue how it is in SUSE but it's easy on my ubuntu, just by clicking on the wifi icon and then connection information). You can also open a console and type ifconfig. ethx is the cable interface and wlanx is the wifi interface. The address should look like 192.168.1.40. Copy and paste that address on the other computer's browser. Shows potato? Then it's all good!

As I've read in Opensuse's apache installation wiki, firewall on opensuse by default blocks all traffic to port 80, so you'll have to unlock it.

So if you need to allow access so that the web server can be accessed from within a LAN we need to fine tune the firewall configuration. The below step needs to be performed as root user. The supplied configurations are called apache2 and apache2-ssl. They can be enabled via YaST, by adding them to FW_CONFIGURATIONS_EXT in /etc/sysconfig/SuSEfirewall2

# sysconf_addword /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT apache2
# sysconf_addword /etc/sysconfig/SuSEfirewall2 FW_CONFIGURATIONS_EXT apache2-ssl
# rcSuSEfirewall2 restart

Now the catch here is NAT. The internet was first designed so each computer in the world had its own unique IP, and each IP had different ports which could be used by the different programs running in the machine. But the internet service providers started to run out of IPs to assign to machines and instead of migrating to ipv6, they created the abhorrent "solution" named NAT, in which you only get a single IP for your router to share in your home. This works by redirecting the packets received to some ports in the router to a computer in the network and the packets received to some other ports in the router to some other computer in the network.

So what's left to do at this point is to tell the router that all packets incoming to router's port 80 should be redirected to the port 80 in your laptop. Because otherwise your router has no clue what to do with them.

Now check if this works by typing your router's IP address on let's say... your phone using data connection. The easiest way to figure it out is to ask google "What is my IP?" Does it show POTATO? Hoorray!

Now, instead of having people type that IP you can register your domain to get you to that IP. But be careful; if you have a dynamic IP instead of a static IP, this means that your IP will change each time you reset your router!!

brunch875

Posted 2013-12-31T01:05:38.937

Reputation: 373

I know I've written a lot of information you might already know, but it's better that way in case you're missing something. – brunch875 – 2013-12-31T01:59:36.717

Thank you @brunch875! Your comment helped me out a lot in places that I had trouble with before. One issue that I am coming across, however, is the problem that although I am running the server on my computer, and localhost works, other computers on the same network are not able to see what I see. What I tried is:

  • ran the server on my machine.
  • copied the ip address of my machine (192.168.1.3).
  • pasted that into another machine on the same network.

It turns out that that approach times out, which is different from what I expected would happen. – Swarage – 2013-12-31T04:30:52.853

You're right. This is because opensuse's firewall by default blocks traffic to port 80. I found a pretty easy way to unlock it. Check it out! – brunch875 – 2013-12-31T17:54:07.493

Thanks again! That was the crux of my problem! Next time I'll be sure to do a bit more research in order to bypass things like these. Again, thanks for all your help! – Swarage – 2013-12-31T19:23:17.130

Ha! The pleasure is mine! I love it when stuff goes right. Enjoy fiddling with your server! In http://www.w3schools.com/ you'll have everything to make an amazing website.

If you're more interested in knowing how the internet works, allow me to recommend you an amazing book which is "Computer Networking: A Top-Down". It's huge and covers everything.

– brunch875 – 2014-01-01T00:23:11.733