EzDevInfo.com

virtual-host interview questions

Top virtual-host frequently asked interview questions

How to go to a website on a shared server by its ip address?

I have a few questions, please help:

Fist, I can access Google search just by typing http://74.125.224.211, because this is the IP address returned by nslookup.

However, I could not do so with the IP addresses returned from www.yahoo.com. How do I go to the Yahoo search page by its IP?

Another example, http://www.allaboutcircuits.com will resolve to 68.233.243.63 by DNS server, but if I go to http://68.233.243.63, I get "Hello world!".

Second, for some reason, there is something wrong with DNS resolvers with my web hosting service (it will not be fixed !!). So commands like

get_file_contents("http://www.allaboutcircuits.com");

will return php_network_getaddresses: getaddrinfo failed: Name or service not known

How do I get around this with IP address,

68.233.243.63

I mean, somehow attach the HTTP hostname parameter to get_file_contents()?

I would like to solve this on my own side (in my code), no troubleshooting/adjustment will be done by the server admin.


Source: (StackOverflow)

Default handling for unmatched domains/subdomains in Apache

I have an Apache2 configuration with multiple VirtualHosts. My DNS is set to accept *.<domain>.<tld> on multiple domains. Everything is working correctly but if I go to something-random-here.example.com I seem to get an invalid VirtualHost being selected (I am guessing the first or last one it finds). Is there a way to tell Apache to use certain rules if none of the VirtualHost entries match the domain or subdomain? I'd preferably like to return a 404.


Source: (StackOverflow)

Advertisements

How to create subdomains on a name-based virtualhost?

I have name-based hosting, lets call it my.address.com. My friend has the 'plain' address address.com and gave me a virtual machine that I can access via SSH.

He also made some magic with ports and now, after installing Apache, I could access /var/www through my.address.com.

So, the question is, how can I make a subdomain like test.my.address.com?

There should be some magic with Apache's Listen Directive, but I cant figure it out. Also, I know how to create local-available sites with Apache, but it is not the same.


Source: (StackOverflow)

How do I create a virtual host that works with both http and https?

This is how I have set up a virtual host:

<VirtualHost mysite> 
  <Directory "/Users/myusername/sitefolder"> 
    Options +FollowSymlinks
    AllowOverride All 
    Order Allow,Deny
    Allow from all
  </Directory> 
  DocumentRoot "/Users/myusername/sitefolder"
  ServerName mysite
  SSLEngine on
  SSLCertificateFile /Users/myusername/certs/server.crt
  SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>

With this configuration, I can view my site only with https, but not http. When I turn SSLEngine off then I cannot view my site with https, but http works fine.

How can I adjust the above lines so that I am able to see my site using both http and https?

I using OSX Lion, but I don't think it matters that much.

Thanks.


Source: (StackOverflow)

Firefox on Ubuntu can't connect to local virtualhost when network is unplugged

I'm using Firefox (3.6.17) on my Ubuntu Lucid (rel. 10.04) and noticed that if the network cable is plugged everything is fine and I'm able to browse my local virtualhost configured in Apache2.

But if I unplug the network, the local vhost is no longer reachable by Firefox and shows the message:

Server not found
Firefox can't find the server at atn-dev.hal901.com

I think Linux and Apache2 are configured correctly because wget and Chromium browser are still able to contact the vhost. It seems to be a Firefox bug.

The problem is I widely use Firefox and I need it for web development. Firefox is only able to reach http://localhost/ when network is unplugged.

I know there is the Firefox "Work Offline" option in the File menu, but I already unchecked it.
Moreover I completely disabled it through the about:config page, setting browser.offline property to false.

Can anyone figure out a solution?


Source: (StackOverflow)

Apache Virtual Hosts on Mac OS X Lion

In /etc/apache2/extra/httpd-vhosts.conf, I have:

NameVirtualHost *:80

<VirtualHost *.80>
    ServerName localhost
    DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>

<VirtualHost *:80>
    ServerName site1.local
    DocumentRoot "/Users/bob/Sites/site1.local"
    <Directory /Users/bob/Sites/site1.local>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *.80>
    ServerName site2.local
    DocumentRoot "/Users/bob/Sites/site2.local"
    <Directory /Users/bob/Sites/site2.local>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

In /etc/hosts, I have:

127.0.0.1     site1.local
127.0.0.1     site2.local

Browsing to http://site1.local yields the correct site. However, browsing to http://site2.local displays Site1's content.

Did I mis-configure something?


Source: (StackOverflow)

Local virtualhost takes too long to load on MAMP

I have a virtualhost "myhost.local" configured in MAMP

My hosts file:

127.0.0.1       localhost
127.0.0.1       myhost.local
255.255.255.255 broadcasthost
#::1            localhost 
fe80::1%lo0     localhost

It worked fine.

After I upgraded my OS to the latest version (Lion), something changed because now Firefox/Chrome take a few seconds to find the myhost.local domain. It's very annoying to develop in these conditions.

It only happens if the domain has not been visited after some seconds (cache?) - any ideas?


Source: (StackOverflow)

Browsing website hosted in the virtual machine from host machine's browser

I have installed Oracle VM Box and created a Virtual machine. Now I have hosted(in IIS) a website in the virtual machine. I want this website to be browsed in the host machine's browser.

Can anybody let me know the settings needs to be configured.


Source: (StackOverflow)

How can I run JIRA on Windows via a subdomain?

I am looking around the JIRA documentation but I cannot find any information on this, but perhaps I'm not searching for the right terms :(

I've heard something about the concept of VirtualHosts in the Confluence documentation but I don't really know where to start; I'm traditionally a .NET developer =)

My JIRA is up and running, i am aware of the xml configuration files in the JIRA\conf directory and can edit what is required.

I have pointed http://jira.mydomain.com to our public IP and am ready to go. It's currently running on http://localhost:8085.

Update: This question is 6 days old and would really love some help, anyone? :|

Thanks in advance.


Source: (StackOverflow)

How to access expired domain host from old DNS record?

I'm trying to access a website whose domain has just expired. The old IP address resolves to 206.225.92.33 which is the parent hosting company and not a dedicated address.

The domain name was registered to godaddy as identified by a WHOIS so it's possible that the website still exists even though the domain does not.

Given an IP 206.225.92.33, is it possible to redirect myself there while convincing the webserver that I want to be redirected to the appropriate virtualhost?


Source: (StackOverflow)

Apache2 2.2.14 setup with multiple virtual hosts for local testing

I have setup an Apache 2 virtual host by this method.

under /etc/apache2/sites-available I've create a dummy_site_1.conf

dummy_site_1.conf

<VirtualHost local.dummy_site_1:80>
    ServerName local.dummy_site_1
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/dummy_site_1
    ErrorLog /var/log/apache2/dummy_site_1__error.log
    TransferLog /var/log/apache2/dummy_site_1__access.log
    <Directory /var/www/dummy_site_1>
        AllowOverride Options Limit None
        Options -Indexes FollowSymLinks
    Order deny,allow
    Allow from all
    </Directory>
    DirectoryIndex index.php
    #DISABLE HTTP TRACE
    #RewriteEngine On
    #RewriteCond %{REQUEST_METHOD} ^TRACE
    #RewriteRule .* - [F]
</VirtualHost>

I also added this line the the httpd.conf:

ServerName local.dummy_site_1

Now all is working with this setup, I type local.dummy_site_1 in the URL and I can see my site.

The problem is when I try to add another site config dummy_site_2.conf and create about the same settings

dummy_site_2.conf

<VirtualHost local.dummy_site_2:80>
    ServerName local.dummy_site_2
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/dummy_site_2
    ErrorLog /var/log/apache2/dummy_site_2__error.log
    TransferLog /var/log/apache2/dummy_site_2__access.log
    <Directory /var/www/dummy_site_2>
        AllowOverride Options Limit None
        Options -Indexes FollowSymLinks
    Order deny,allow
    Allow from all
    </Directory>
    DirectoryIndex index.php
    #DISABLE HTTP TRACE
    #RewriteEngine On
    #RewriteCond %{REQUEST_METHOD} ^TRACE
    #RewriteRule .* - [F]
</VirtualHost>

I also added this line the the httpd.conf:

ServerName local.dummy_site_2

I get this error:

user@host:/etc/apache2$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                                                                                                                                     [Wed Sep 15 14:00:43 2010] [error] (EAI 5)No address associated with hostname: Could not resolve host name local.dummy_site_2 -- ignoring!
 ... waiting [Wed Sep 15 14:00:44 2010] [error] (EAI 5)No address associated with hostname: Could not resolve host name local.dummy_site_2 -- ignoring!

Why? am I configuring this wrong?


Source: (StackOverflow)

Configure Apache to serve multiple subdomains via HTTP + HTTPS

I have a virtual server hosted at ISP with 2 public IPv4 addresses. I want to run several subdomains (more than 2) with Apache and serve them via both HTTP and HTTPS. The SSL cert is a wildcard one for *.mydomain.com.

I tried to configure Apache in Debian this way but failed. Either my virtualhosts are not accepted or I get SSL errors. (I know that Apache doesn't see hostname requested before serving the cert but the cert includes all subdomains possible)

Please help to create an httpd.conf that works best with Debian's Apache config layout.

All the details:

  • Apache listening on *:80 for HTTP and *:443 for HTTPS
  • All NameVirtualHosts, aliases etc. shall be defined for both ports/protocols at once
  • default mydomain.com and www.mydomain.com should root to /var/www
  • additional NameVirtualHosts for foo.mydomain.com and bar.mydomain.com etc. which can be configured specially, e.g. to have another DocumentRoot

Source: (StackOverflow)

httpd on CentOS resolving only the first VirtualHost

I just got a new cloud server and while setting it up, I can access the web root by pointing my browser to the IP address of my server, but the domain names are still propagating so when I go to them, they do not resolve.

When I do point my browser to the IP address of my server, it is actually resolving to the first VirtualHost that I set up which should not be the root folder. This VirtualHost should show up when I go to ipaddress/path, not just ipaddress.

Server setup:
Host: Rackspace Cloud Server
OS: CentOS 6
VirtualHosts:

<VirtualHost *:80>
    ServerAdmin www.wphax.com@gmail.com
    ServerName www.wphax.com
    ServerAlias wphax.com *.wphax.com
    DocumentRoot /var/www/wphaxcom
    ErrorLog /var/www/wphaxcom/error.log
    CustomLog /var/www/wphaxcom/access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin www.wphax.com@gmail.com
    ServerName www.dnadvanced.com
    ServerAlias dnadvanced.com *.dnadvanced.com
    DocumentRoot /var/www/dnadvancedcom
    ErrorLog /var/www/dnadvancedcom/error.log
    CustomLog /var/www/dnadvancedcom/access.log combined
</VirtualHost>

Any ideas what could cause this, and how I could set it up so the root directory is not accessible by entering the IP address, but the domain names will resolve correctly to their specified folders? Thanks.


Source: (StackOverflow)

Apache2 Virtual Hosts not recognizing properly

I have two virtual hosts, but apache seems to be defaulting to one of them.

Here is host #1:

<VirtualHost *>

        ServerName goiclub.com
        ServerAlias www.goiclub.com *.goiclub.com
        ServerAdmin webmaster@localhost

        DocumentRoot /home/casey/public_html/goiclub/public

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/casey/public_html/goiclub/public>
                DirectoryIndex index.php index.htm index.html
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>



        ErrorLog /home/casey/public_html/goiclub/log/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel debug

        CustomLog /home/casey/public_html/goiclub/log/access.log combined
        ServerSignature On

        Alias /doc/ /usr/share/doc/
        <Directory "/usr/share/doc/">
                Options Indexes MultiViews FollowSymLinks
                AllowOverride None
                Order deny,allow
                Deny from all
                Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>

</VirtualHost>

And this is the other vhost:

<VirtualHost *>
ServerAdmin webmaster@geticlub.com
ServerName geticlub.com
ServerAlias www.geticlub.com *.geticlub.com

DirectoryIndex index.php
DocumentRoot /home/casey/public_html/geticlub/public

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /home/casey/public_html/geticlub/public>
                DirectoryIndex index.php index.htm index.html
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

LogLevel debug
ErrorLog /home/casey/public_html/geticlub/log/error.log
CustomLog /home/casey/public_html/geticlub/log/access.log combined
</VirtualHost>

whether I type in goiclub.com or geticlub.com it returns 'geticlub.com' vhost. Does anyone know why?

Also this might be helpful:

sudo apache2ctl -t -D DUMP_VHOSTS
apache2: Could not reliably determine the server's fully qualified domain name, using 50.56.118.158 for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:*                    geticlub.com (/etc/apache2/sites-enabled/geticlub.com:1)
*:*                    goiclub.com (/etc/apache2/sites-enabled/goiclub.com:1)

Source: (StackOverflow)

Is it possible to run Virtual Hosts (or equivalent) across several servers, but one public IP, using Tomato?

Here's my home setup. I have a single IP address provided by my ISP. I have one top-level-domain (TLD) and several sub-domains that point at that IP. Internet comes in through my cable modem and plugs into my AdvancedTomato router. I want to install several web servers on separate machines and have the router forward the traffic based upon the domain name. Here's a basic picture

    Internet
    |
    |
    └── example.com-x.x.x.x(router)
        ├── machine1-192.168.1.101
        │   ├── project11.example.com
        │   └── project12.example.com
        ├── machine2-192.168.1.102
        │   ├── project21.example.com
        │   └── project22.example.com
        └── machine3-192.168.1.103
            ├── project31.example.com
            └── project32.example.com

I have been able to do this already on a single machine using basic port forwarding on the router (everything on port 80 goes to machine1), then using Apache's VirtualHost's on that machine to open different websites.

    Internet
    |
    |
    └── example.com-x.x.x.x(router)
        ├── machine1-192.168.1.101
            ├── project11.example.com
            └── project12.example.com

My question: is it even possible to do this at the router level? If not, how do large websites set this up.I know HTTP is at the application level, and that's where the domain request is, so can the router even look at that information? Would I need a proxy server?

Also, should this be on server fault instead?


Source: (StackOverflow)