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

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
        </Directory>
</VirtualHost>

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?
CarboneczAsked:
Who is Participating?
 
Steve BinkCommented:
You can modify your hosts file to provide resolution for the subdomain:
127.0.0.1 sub.localhost

Open in new window

The hosts file is found in /etc on *nix, and in %WINDIR%\system32\drivers\etc on Windows.
0
 
CarboneczAuthor Commented:
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?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.