We help IT Professionals succeed at work.

ssh tunnel to port 80 + vhosts + serveralias + virtualdocumentroot not working

Carbonecz asked
Last Modified: 2014-10-21
I have a remote server with all ports disabled except 22 (ssh). I use Putty to connect to the server with a forwarded port (Source port: 8080 Destination: *.*.*.*:80). When I open a browser and put localhost:8080 in I get the appropriate webpage.

Now I want to have subdomain virtual hosts like this: subdomain.localhost:8080. Subdomain being the name of a folder.

I've tried this:

<VirtualHost *:80>
        UseCanonicalName On
        ServerName sub.domain.com
        ServerAlias *.domain.com
        VirtualDocumentRoot /var/www/%1
        <Directory />
                Options FollowSymLinks
                AllowOverride All

Open in new window

When I try to access "localhost:8080" with "UseCanonicalName On" in chrome it returns "NOT FOUND Apache/2.2.16 (Debian) Server at sub.domain.com Port 80" (I figured out it tries to find an index in "sub" folder)

When it's "UseCanonicalName Off" it returns "NOT FOUND Apache/2.2.16 (Debian) Server at localhost Port 8080".  (tries to find an index in "localhost" folder).

In both cases when I try to access "sub.localhost:8080" chrome returns ERR_NAME_NOT_RESOLVED.

They seem to be separate issues. In first two cases no matter what I try it never registers ServerAlias. In the third one it doesn't seem to even make it to the server.

Can you help me with this?
Watch Question


I've just found out that you can use lvho.st for localhost subdomains.

"sub.lvho.st:8080" instead of "sub.localhost:8080".

This seems to solve all issues. I don't like to rely on this website though. Is there a better solution?
Top Expert 2004
This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.