0

I have set up an apache instance on my ubuntu server in my internal home network. Its internal address is 192.168.1.70. When I visit http://192.168.1.70 I get the standard "It Works!" page of apache.

For testing purposes, I have put a php info page (info.php) in /var/www. When I visit http://192.168.1.70/info.php I see the standard PHP version + info page.

I have also set up wordpress under /var/www/wordpress as well as another info.php under that same directory. When I visit http://192.168.1.70/wordpress/info.php I am getting the same PHP page as above, which is fine.

But, when I visit http://192.168.1.70/wordpress, instead of seeing the wordpress homepage, I see my browser being redirected to this: http://192.168.1.70:9980/wordpress and showing a "could not connect to 192.168.1.70:9980" error.

Where did this magic port number come from? Let me help with some background. Earlier today I was managing my ubuntu server remotely from work by ssh-ing to it using the following command:

ssh -p ssh_port -L 9980:localhost:80 username@server

in order to be able to test it locally using the http://localhost:9980/wordpress URL, as the computer I was using wouldn't allow me to forward ports < 1024.

The contents of /etc/apache2/ports.conf are:

NameVirtualHost *:80
Listen 80

Why is my browser being redirected to http://192.168.1.70:9980/wordpress? Why is port 9980 being used and where is it coming from? Can someone please help out?

Thanks

Edit: I have just restarted my router at home but the problem persists.

Edit: The output of curl -I http://192.168.1.70 is:

HTTP/1.1 200 OK
Date: Thu, 09 Jan 2014 02:06:51 GMT
Server: Apache/2.2.22 (Ubuntu)
Last-Modified: Wed, 08 Jan 2014 18:05:15 GMT
ETag: "a39cd-b1-4ef7955bf7f23"
Accept-Ranges: bytes
Content-Length: 177
Vary: Accept-Encoding
Content-Type: text/html
X-Pad: avoid browser bug

Edit: The output of curl -I http://192.168.1.70/wordpress/info.php is:

HTTP/1.1 200 OK
Date: Thu, 09 Jan 2014 02:08:04 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.9
Vary: Accept-Encoding
Content-Type: text/html

Edit: The output of curl -I http://192.168.1.70/wordpress/ is:

HTTP/1.1 301 Moved Permanently
Date: Thu, 09 Jan 2014 18:51:51 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.9
X-Pingback: http://localhost:9980/wordpress/xmlrpc.php
Location: http://192.168.1.70:9980/wordpress/
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
  • Please post the output of `curl -I http://192.168.1.70/wordpress`. – Andrew Schulman Jan 09 '14 at 01:31
  • Thanks for your response. The output is: `HTTP/1.1 301 Moved Permanently Date: Thu, 09 Jan 2014 01:55:22 GMT Server: Apache/2.2.22 (Ubuntu) Location: http://192.168.1.70/wordpress/ Vary: Accept-Encoding Content-Type: text/html; charset=iso-8859-1` – user3175555 Jan 09 '14 at 01:55
  • I haven't made any progress on this, people have been referring me to the ssh man pages on how tunneling works, but I have been successfully used tunnel numerous times in the past. This is the first time though that the port and hostport were different in -L port:host:hostport. – user3175555 Jan 09 '14 at 16:35
  • Your output shows that `http://192.168.1.70/wordpress` is being redirected to `http://192.168.1.70/wordpress/`, which is normal. So please replace that by the output of `curl -I http://192.168.1.70/wordpress/`, which will show us what's going on. – Andrew Schulman Jan 09 '14 at 16:39
  • Thanks again - I think we are getting somewhere. I have now added the output of the curl command you suggested. – user3175555 Jan 09 '14 at 18:52

2 Answers2

0

This may sound silly, but are you sure it's not your browser "helping" by substituting an entry from your browsing history? Chrome is especially aggressive about that. Try clearing your browsing history, then trying again.

Andrew Schulman
  • 3,395
  • 1
  • 21
  • 23
  • Thanks for your response. I am trying to visit the wordpress page from a different computer at home (tried Safari and Chrome), than I did earlier at work. I also tried using my mobile's browser, all while I was connected to the same local network as the ubuntu server. The result is always the same. – user3175555 Jan 09 '14 at 01:59
0

The output of curl -I http://192.168.1.70/wordpress/ that you posted shows that Apache is issuing a redirect from there to http://192.168.1.70:9980/wordpress/. So, there must be a redirect to port 9980 somewhere in the Apache configuration. Try running

grep -r 9980 /etc/apache2

Or, enable mod_info if you haven't already, and restart Apache. Then go to http://192.168.1.70/server-info, and search the page there for 9980.

Andrew Schulman
  • 3,395
  • 1
  • 21
  • 23
  • Thanks for your reply - I did this before, but tried it again just now. Unfortunately `grep -r 9980 /etc/apache2` returns nothing. It is a very strange coincidence that the port that causes the problem is the one I used for tunnelling. Why would `http://192.168.1.70` work fine, whereas `http://192.168.1.70/wordpress` would get redirected to `:9980`? I am still very confused - any other ideas? – user3175555 Jan 09 '14 at 19:43
  • I added another suggestion above, using mod_info. – Andrew Schulman Jan 09 '14 at 20:15
  • Is it your Apache that's listening on port 80? Run `sudo netstat -nap | grep ':80.*LISTEN'`, and make sure that apache2 is shown listening on 192.168.1.70:80. – Andrew Schulman Jan 09 '14 at 20:45
  • Yes. Here's what I got: `tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 16767/apache2` – user3175555 Jan 09 '14 at 20:48
  • Also, I just enabled mod_info and 9980 is nowhere to be found in the `http://192.168.1.70/server-info` page – user3175555 Jan 09 '14 at 20:54
  • The only thing left I can think of is that the redirect is coming from Wordpress, though I have no idea why. – Andrew Schulman Jan 09 '14 at 21:17