Browser redirected to a URL address with a port number from a previous SSH tunnel session

1.8k Views Asked by At

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
2

There are 2 best solutions below

1
On

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.

6
On

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.