Preview in a webbrowser on a virtual server?

Discussion in 'Site & Server Administration' started by crazyhorse, Feb 7, 2005.

  1. #1
    Hi

    On my vitual server im running two domains. With the ip of the virtual server im able to preview the main domain, but how can i preview the second domain. Are there any tools available for this or is there a certain command line.
    :eek:

    Thanks in advance
     
    crazyhorse, Feb 7, 2005 IP
  2. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Configure the site in apache.

    If you only have 1 ip address, use name based virtual hosting (google will give you plenty of info, as will the apache documentation).

    Since you are using a name, but not a live domain, add the name/ip combination to your hosts file.

    so your hosts file could say
    www.mytestsite.com 246.132.194.589

    Then when you open up the browser on your computer, and go to www.mytestsite.com it will actually go to your server at address 246.132.194.589

    When you want to go live, you'll probably need to adjust your apache config, but that should do it for now.

    Alternatively, you could set up a subdomain for your live site - like test.yourdomain.com and configure your test site to be at test.yourdomain.com
     
    nevetS, Feb 7, 2005 IP
  3. mopacfan

    mopacfan Peon

    Messages:
    3,273
    Likes Received:
    164
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What OS is your server using? If it's unix, then nevets is probably on target, if not, then he's way off in left field.
     
    mopacfan, Feb 7, 2005 IP
  4. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Virtual domains are identified by the Host HTTP header. For example, you you wanted to see HTTP headers returned by your virtual domain, you can type this at the command line:

    $ telnet my-domain.com 80
    GET / HTTP/1.1<Enter>
    Host: my-domain.com<Enter>
    <Enter>
    Code (markup):
    Keep in mind, once you are connected, you cannot use or delete keys anymore and if you make a mistake typing any of this, you will have to start all over again.

    In general, all browsers will form the Host header based on what you typed in the URL line.

    J.D.
     
    J.D., Feb 7, 2005 IP
  5. crazyhorse

    crazyhorse Peon

    Messages:
    1,137
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks lets see i can do that as well.
     
    crazyhorse, Feb 7, 2005 IP
  6. crazyhorse

    crazyhorse Peon

    Messages:
    1,137
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Does your above command line work as well for SSH. I jsut read on the help page of my host that they dont support telnet anymore. Cause of security reasons.
     
    crazyhorse, Feb 7, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If your machine is visible from your office/home connection, you can use telnet to hit your public IP address. If you are just testing, first, SSH to your machine, then use telnet inside. Telnet isn't secure and it's a good thing your hosting company doesn't allow you to connect from the outside.

    J.D.
     
    J.D., Feb 7, 2005 IP
  8. crazyhorse

    crazyhorse Peon

    Messages:
    1,137
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ok so i first need to start up SSH and once im inside on the virtual server i should use telnet right?
     
    crazyhorse, Feb 7, 2005 IP
  9. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #9
    It all depends on whether you can see your virtual website from outside. If you can, then just run telnet on your office/home machine and hit your machine in IDC. You can use the public IP address if your DNS isn't set up yet (e.g. telnet <public-ip-address> 80).

    If you are just setting your machine up and this website isn't visible from the outside, then SSH to your machine, then run telnet from inside (you can use either public or private IP address in this case).

    You can also turn on logging in telnet to capture the entire HTML and view it later in a browser (just don't forget to strip off the headers in a text editor).

    J.D.
     
    J.D., Feb 7, 2005 IP
  10. crazyhorse

    crazyhorse Peon

    Messages:
    1,137
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Ok thanks im going to give it a try when i get back home. Thanks for the info much appreciated. ;)
     
    crazyhorse, Feb 7, 2005 IP
  11. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #11
    Oh yeah. I forgot about that other web server...
     
    nevetS, Feb 7, 2005 IP
  12. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #12
    J.D., Feb 7, 2005 IP
  13. crazyhorse

    crazyhorse Peon

    Messages:
    1,137
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #13
    What if i have two different directories would that make a difference. The DNS isnt resolved yet. I got a html directory and a htnl2 directory , in this last one my new website is located.
     
    crazyhorse, Feb 7, 2005 IP
  14. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I'm assuming your test virtual website is configured to point to html2 and your main website points to html. If this is correct, then you can connect to the same IP address and the web server will pick the website based on the value of the Host header. For example,

    telnet 127.0.0.1 80
    GET /index.html HTTP/1.0
    Host: my-host-1.com

    will return the file test.html from the root directory of the my-host-1.com website (e.g. html).

    telnet 127.0.0.1 80
    GET /index.html HTTP/1.0
    Host: my-host-2.com

    will return the file index.html from the root directory of the my-host-1.com website (e.g. html2)

    You can also modify your hosts file or add an entry to your local DNS server and create a temporary domain name you are planning to use for the new website. In this case, you will just be able to access your test website using any browser.

    J.D.
     
    J.D., Feb 8, 2005 IP
  15. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135