Slow web response on first request - apache

I have a website, deployed on 2 identically configured servers - Ubuntu 14.04 / apache2 / MySQL / php. One is in a VM, the other is a physical box. Both servers behave the same.
The first request to go to a web page times out when sent from inside the local network, but responds fine from outside. So if I click on a link or a menu item on the web page, or call up a web page from a browser it times out. If then make a request for a web page it responds immediately and on all subsequent request, unless I leave it alone for over 20 seconds, then the next response will time out. If I click on one link, then wait 2 or 3 seconds, then click on the same or another link it responds. If I click a link, then click a link in another browser after 2 or 3 seconds it responds instantly.
My router is set up to redirect links from outside to the same server. When I make a request to the public address remotely it always responds instantly - no latency. This shows it's not the disk, or application pools or whatever else may take some time to spin up, it's something to do with accessing it locally. The same thing also happens with telnet, MySQL workbench and ftp with both machines. Nothing unusual in the apache logs, it seems the first request just doesn't get there.
I think it's probably my network config. I have a reason for the Ubuntu servers to be on a separate subnet, but I'm currently combining them. The servers are static IPs at 192.168.0.10 and 11, with a mask of 255.255.254.0.
I'm accessing them from machines in the 192.168.1.xx network, also with a mask of 255.255.254.0. Pings seems to go both ways instantly. It's really frustrating trying to test web updates when firstly the ftp has to be done twice and then the clicks have to be done twice if I leave it more than 20s.

Not many views of the question so probably nobody is interested anyway, but I found the answer.
I had a VMware virtual network set up at 192.168.0.0 for when I'm on a train (or at least not at home) so that I can communicate with my VM server by connecting the VM network adapter with the virtual network instead, preserving the static IP address. Even when I have the VM connected directly to the home network, the virtual network is still active on the PC which meant there are 2 separate networks in that range which obviously confuses things and takes a while to sort out. I guess it has to wait for one to time out before trying the other. Anyway, disabling the VMware virtual network when I'm at home sorts out the problem.

Related

Mobile Access from Digitalocean apache2 connection timed out

I'm using Digitalocean cloud hosting server and apache2 in Ubuntu 16.04 VPS. I can browse the site from my local PC and check apache access.log to see the page requests. However when using a mobile device, I cannot get a response from the website. I can ping the server IP address from my phone successfully. However, any requests for the domain root do not create any record in the access.log.
I have attempted to uninstall fail2ban as per this threads:
https://www.digitalocean.com/community/questions/how-to-debug-solve-a-err_connection_timed_out-error-when-this-error-happens-on-some-browsers-but-not-in-another
http://installion.co.uk/ubuntu/vivid/universe/f/fail2ban/uninstall/index.html
I have also tried simply serving a phpinfo() page. However, no still no records in access.log when trying to access from mobile devices. The site is has https enabled and is serving perfectly to a PC.
Also, using a browser testing site (https://www.browserstack.com/) I also get connection timed out errors, and no response records in the access.log.
Any suggestions on where to start troubleshooting this? Is this possibly a problem with Digitalocean itself? Is there anything in the LAMP stack that would specifically be blocking some browsers or IP addresses?
It sounds to me like one of two things is happening here:
Your DNS is not set to point to that IP, but you set it in your operating system's host file on your computer.
Your DNS is correct, but other systems are not yet seeing the change you've made.
Try visiting the IP of the server directly from your mobile device. If anything occurs besides timing out, be it a redirect (even if failed) or a page load, you will know that DNS resolution is the issue. Given that you can ping the IP from your phone I would suggest fail2ban is not related, as fail2ban should block ping as well.
If it turns out to be #2 there, it's just a game of waiting. DNS changes can take up to 48 hours to be seen by all systems. In most cases 4-6 hours is common, but 48 hours is still the recognized standard of "it could possibly take this long."
Jarland

cannot access website from within my network

A website prodecotech.com is hosted by Bluehost
Out of the blue last week my entire office could not access prodecotech.com the connection would time out.
However this is only the situation from one of our internet connections. If I switch over to a guest connection, or use a mobile connection, the website loads fine. The website also loads perfectly fine for ATT and BlueHost tech support.
Our network is configured as follows.
We have a 50MB Dedicated Fiber Connection from an ATT Managed Router. The managed router has 2 ports in use. 1 Port going to OUR router for Data traffic and 1 Port going to OUR switch for VOIP Traffic.
If I connect a laptop to OUR router managing data traffic and try to access prodecotech.com, I get the same results, the connection times out.
If I connect a laptop to the switch managing VOIP traffic, prodecotech.com loads fine.
If I use our guest wifi which is through Comcast, the website loads fine as well.
So the problem is isolated to the Data Portion of my network.
There has been no configuration changes on our router or the managed ATT router.
I thought perhaps somehow our IP got blacklisted by BlueHost, but BlueHost says this is not the case.
ATT support is able to reach the website through their managed router.
I'm utterly stumped.
Additionally, I also cannot access the FTP or CPANEL Server Status for this hosting, both time out as well.
TRACERT has been giving me the following results consistently:
Any Ideas?
In my case, it was due to the wrong MTU(maximum transmission unit) in the router's network configuration. When I changed MTU to 1452 it started working fine.
You should contact your service provider and ask for appropriate configuration settings.

Understanding Apache Traffic

I run a 2GB RAM Linode (Ubuntu) that hosts a few WordPress websites. Recently my server has been OOMing and crashing and I have been up all night trying to find out what's causing it. I have discovered there I get an enormous influx of traffic (a tiny DoS) that brings the whole thing down.
I have access logs setup across all of the virtual hosts and I am using tcptrack to monitor activity on the server.
The traffic appearing in my access logs does not account for the traffic I am seeing on tcptrack. i.e. there are a dozen i.p. addresses that are constantly opening and closing connections on the server, but are nowhere to be seen in the access logs for each virtual host.
Clearly it's because these i.ps are not hitting the virtual hosts, but I have tried to set up access logs to monitor server-wide traffic so that I can see what requests their making but I'm really struggling.
Can anyone please point me in the right direction, perhaps tcptrack is just too simplified to provide any meaningful insight?
Start using mod_security
https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#Installation_for_Apache
Debian has it which means Ubuntu likely does as well. You should also make sure the kernel is setup properly, search google for SYN_COOKIES. Look into iptables/shorewall etc. Shorewall is a package that wraps iptables. Iptables can be configured for detect floods and start dropping packets.

All Google API Calls From Our Office Time Out

We have a small office with 20+ computers that are about 80/20 split Macs vs. PCs. I am a web developer by trade who manages our little network but am, by no means, a networking/DNS expert.
That being said, we are having trouble in that every single web site we visit (stackoverflow.com included) that makes a call to a Google API takes forever to load. They all get stuck with a statusbar message such as: "Connecting to fonts.googleapis.com, ajax.googleapis.com, developers.google.com etc..." Eventually, the api call times out and the site will then load without it. Sometimes we get a pop-up error "accounts.google.com" failed to respond. In fact, when we finally get Stack Overflow to load this message is at the top of the page: "Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load."
This seems to be only happening on our internal network. For instance, we can connect laptops, phones and tablets to LTE/mobile networks and they load up the same sites fine.
Oddly enough, Google.com, itself, loads fine. As do Gmail and Google Docs.
When I ping 'fonts.googleapis.com' from both inside the network and from our firewall I get "Request timed out" for 'googleapis.l.google.com' [74.125.70.95].
I have tried deleting all Google entries from our DNS server, an old Windows 2003 Small Biz Server, which sometimes results in 'googleapis.l.google.com' getting a different IP address from our ISP which alleviates the issue temporarily. But, it seems eventually this same IP of 74.125.70.95 will get tacked on to the API URL and we're back in the same boat.
I tried changing the DNS server address of our Win2003 SBS server, itself, away from our ISP's address to both OpenDNS and Google's own DNS server but this hasn't helped.
This has been happening for about a month.
Any ideas?
Stumbled on this article:
http://www.sophos.com/en-us/support/knowledgebase/2450/2750/4350/120934.aspx
Essentially it details something I hadn't thought about. My firewall's Country Blocking feature. Even though the particular IP I had trouble with seemed to belong to Google here in the US, it may have been routed through China (or my firewall's IP address tables are outdated) so traffic was being blocked.
I've adjusted FW rules to allow this IP and all is well.

Cocoa server with user friendly automatic port forwarding or external ip lookup

I am coding a mac app, which will be a server that serve files to each user's mobile device.
The issues with this of course are getting the actual ip/port of the server host, as it will usually be inside of a home network. If the ip/port changes, its no big as i plan to send that info to a middle-man-server first, and have my mobile app get the info from there.
I have tried upnp with https://code.google.com/p/tcmportmapper/ but even though I know my router supports upnp, the library does not work as intended.
I even tried running a TURN server on my amazon ec2 instance, but i had a very hard time figuring how what message to communicate with it to get the info i need.
I've been since last night experimenting with google's libjingle, but am having a hard time even getting the provided ios example to run.
Any advice on getting this seemingly difficult task accomplished?
The port of your app will not change. The IP change could be handled by posting your servers IP to a web service every hour or whatever time period you want.
Server should run a URL http://your-web-service.com/serverip.php?ip=your-updated-ip and then have your serverip.php handle the rest (put it into a mySQL db or something)
When your client start it should ask your site for the IP and then connect to your server with that.
This is a pretty common way of handling this type of things.