LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-01-2011, 11:50 AM   #1
123Linux321
LQ Newbie
 
Registered: Apr 2011
Posts: 14

Rep: Reputation: 0
Apache server behind a router


Hi,

I am running an apache2 server in ubuntu. When I connect my laptop directly to my modem, I can access my web page (from any computer or phone) without any problems.

I start getting weird issues when I try running my web server behind my DLink 524 router. It will run perfectly for about an hour or so then the web page will become inaccessible from any computer except the one which I am running my server on. I have made sure to forward and requests to port 80 on my machine and I have also set the router firewall to allow access through port 80 and port 443. I don't get any error messages in my apache2 log when my site goes down.

Since the site worked perfectly when my computer was connected directly to my modem, I figure it has to be a router problem. Anyone have any suggestions as to what the problem might be?

Thanks for the help.
 
Old 05-01-2011, 02:22 PM   #2
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Originally Posted by 123Linux321
It will run perfectly for about an hour or so then the web page will become inaccessible from any computer except the one which I am running my server on.
Is it also inaccessible if you try to access it using the LAN IP address (obviously from another computer on the same LAN)?

The reason I'm asking is that sounds kind of like the behavior one might get from a tool like fail2ban, but I've never heard of one being put in front of a web server.

Also, if you reboot just the router, does the problem go away for another hour or so? And does the router have any logging capability?
 
Old 05-01-2011, 07:33 PM   #3
123Linux321
LQ Newbie
 
Registered: Apr 2011
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks for your response.

I have 3 computers on my LAN (including the one with my server on it). Usually when it goes down none of the computers on my LAN have access to it; it went down this morning however, and one of the computers on my LAN was able to access it...weird.

I haven't tried to rebooting the router, I do reload the server ("sudo /etc/init.d/apache2 reload") and it will work again perfectly (for a certain amount of time). The router does have basic logging.
 
Old 05-01-2011, 09:39 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,317
Blog Entries: 28

Rep: Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140
Two questions:

Does your server had a static ip address?

Is port forwarding for port 80 (or whatever port you are using) set up in your router?

The only correct answer to both questions is "Yes."
 
Old 05-01-2011, 10:40 PM   #5
thinmintaddict
LQ Newbie
 
Registered: Apr 2011
Location: Austin, TX
Distribution: Arch Linux
Posts: 12

Rep: Reputation: 6
That's not true, he can host with a dynamic IP no problem if he needs to. There's detailed instructions on my site. But that's beside the point.

What 123linux321 was asking about your LAN IP is this: when it's down by hostname, can you still access it by pointing to the LOCAL ip of your server? (192.168.1.xxx or 192.168.0.xxx, etc.)

Additionally, if you leave it up connected only to the modem, does it continue to work indefinitely? (not cutting out after an hour or so?) I know that it's a pain to take your entire network off the internet for that long, you can skip this for now, and we'll see if we can resolve it without this step.
 
Old 05-02-2011, 09:05 AM   #6
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Originally Posted by 123Linux321
I haven't tried to rebooting the router, I do reload the server ("sudo /etc/init.d/apache2 reload") and it will work again perfectly (for a certain amount of time).
You've said that you don't get any error messages in your apache2 logs when the site goes down, but do the attempts leave any messages at all? In theory, access_log should contain a record of the attempt if Apache sees it.
 
Old 05-02-2011, 12:59 PM   #7
123Linux321
LQ Newbie
 
Registered: Apr 2011
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks for the responses everyone!

I do not have a static ip address, and yes I am forwarding all my requests to and from port 80.

If I connect my server directly to my modem it works indefinitely; I had it running for 5 days straight without any issues before I disconnected it.

The attempts to connect to my server do not leave any messages.

I have increased the timeout time, and the max amount of keepalive requests and am currently waiting to see if this improved anything - maybe this would help at times if I have a poor wireless connection?

It's been running without any issues since 9 this morning; if it goes down again then I will try to access it on my LAN via its local address and see what happens...so far so good though.
 
Old 05-02-2011, 01:45 PM   #8
123Linux321
LQ Newbie
 
Registered: Apr 2011
Posts: 14

Original Poster
Rep: Reputation: 0
so it just went down again, none of my computers were able to access it via my modem's ip address. One of the computers was able to access it via its local ip address however the others were not.

I included my apache2 configuration files in the attached text file - maybe something is wrong over there?

The files included are apache2.conf,ports.conf,envars, and 000-default which is the only file in the sites-enabled folder. The httpd.conf file is blank. Everything in the conf.d folder are the default settings, I haven't changed them.

Thanks everyone.
Attached Files
File Type: txt apache2.txt (10.8 KB, 70 views)

Last edited by 123Linux321; 05-02-2011 at 01:47 PM.
 
Old 05-02-2011, 02:39 PM   #9
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Originally Posted by 123Linux321
I do not have a static ip address, and yes I am forwarding all my requests to and from port 80.
I think the question was does the server have a static IP address on the LAN. In other words, is it possible that at some point there is a DHCP renewal that results in a new IP address for the server and therefore, port forwarding is pointing to the wrong IP address. And could you explain by what you mean by forwarding "from" port 80? On all of the routers I've ever used, you only forward to a port.

Quote:
Originally Posted by 123Linux321
If I connect my server directly to my modem it works indefinitely; I had it running for 5 days straight without any issues before I disconnected it.
As long as you're not messing with the apache configuration, I think this really points towards the router not being able to handle things. I really think that to narrow this down, you're going to have to test things one at a time. I'd set the server up and when it goes down next, reboot just the router and do nothing else. Also, could you borrow a different router from someone? If the same thing happens with two routers, then it is likely the server, but if a different router solves the problem, well, then we know you've got a bum router.


Quote:
Originally Posted by 123Linux32
The attempts to connect to my server do not leave any messages.
Which means either the packets are no longer getting to the server, or Apache is no longer listening. Next time it goes down, maybe take a look at see if Apache is still active and listening. netstat -pane | grep LISTEN should give you an idea. However, based on the fact that this only happens when the router is present, I'm still thinking that is the main "item of interest".

Quote:
Originally Posted by 123Linux321
I included my apache2 configuration files in the attached text file - maybe something is wrong over there?
Nothing jumps out at me. Maybe someone else sees something.
 
Old 05-02-2011, 08:13 PM   #10
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,317
Blog Entries: 28

Rep: Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140
Quote:
Originally Posted by Hangdog42 View Post
And could you explain by what you mean by forwarding "from" port 80? On all of the routers I've ever used, you only forward to a port.
Actually, it's both. The router forwards calls received on port 80 from the Big Wide World to port 80 on the designated computer.

If the server is DHCP on the local network, its local IP on the local network is subject to change with every reboot, depending on the other devices on the network and the DHCP configuration in the router.

Since the OP's computer receives the network calls when it's connected directly to the modem, which will pass through port calls, but not when the router is introduced into the mix, I think the solution lies with the router.
 
Old 05-03-2011, 08:01 AM   #11
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Quote:
Originally Posted by frankbell
Actually, it's both. The router forwards calls received on port 80 from the Big Wide World to port 80 on the designated computer.
I'm probably being obtuse about what I mean. Absolutely, the router has to forward calls on port 80 to the designated server. What I was wondering about was if somehow 123linux321 was restricting the response to that call. The response is almost certainly going to be on some random high port, so if 123linux321 has somehow restricted the outgoing ports, that might explain some of the problem.

Quote:
Originally Posted by frankbell
Since the OP's computer receives the network calls when it's connected directly to the modem, which will pass through port calls, but not when the router is introduced into the mix, I think the solution lies with the router.
Unfortunately this is a slight oversimplification. When the server is connected to the router, it works for a bit, then stops. Since this never happens when the server is directly connected to the modem, I agree, this seems to suggest the router is somehow getting borked, but we need some more info before we can send a SEAL team in to take it out.
 
Old 05-03-2011, 02:22 PM   #12
123Linux321
LQ Newbie
 
Registered: Apr 2011
Posts: 14

Original Poster
Rep: Reputation: 0
Hi,

I do have a static LAN address.

I just noticed some weird behaviour, and I don't know if it's related. If I turn off the apache2 server and enter my ip address in my browser, I still get directed to my site. Would anyone know why this is happening. If I enter http://localhost then it WON'T take me to my site (which would be the expected result).

I edited the configuration so that it won't even listen to any requests from my IP address but my site still comes up if I enter my IP address into my browser.

I reloaded apache after all these changes.
 
Old 05-03-2011, 08:21 PM   #13
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,317
Blog Entries: 28

Rep: Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140Reputation: 6140
Thanks, Hangdog42. I have to work on my reading comprehension.

OP, could this new behavior be from the browser's cache? Try another browser, preferably one you haven't used to look at the site before. If you usually use Firefox, try the native Gnome browser, Epiphany.
 
Old 05-08-2011, 03:25 PM   #14
123Linux321
LQ Newbie
 
Registered: Apr 2011
Posts: 14

Original Poster
Rep: Reputation: 0
I used epiphany and didn't get that same behaviour, thanks. As for the problems with my server I am going to assume it is a router problem. I'm going to try and get my hands on a new one soon and hopefully I won't have any more problems. Thanks everyone.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Network configuration: server - router vs router-server alistair_sunde Linux - Networking 2 08-14-2010 09:19 AM
Problems accessing Apache server On Suse 10.3 Linux, behind a Lynksys WRT54GS router mrukjames Linux - Server 1 10-04-2008 02:49 PM
Apache 2 web server behind NAT router rober Fedora 4 12-15-2004 07:07 AM
apache server from behind router drigz Linux - Networking 4 05-16-2004 02:31 PM
problems setting up apache and vsftp server behind a router that serves as a server xone Linux - Security 1 04-08-2004 10:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration