viewing site on local network

Discussion in 'General' started by kwickcut, Oct 4, 2017.

  1. kwickcut

    kwickcut Member HowtoForge Supporter

    hello i have one web server up and running for the past 5 years i just built a new box and have installed ubuntu 16.04 perfect server. i am in the middle of moving files and databases over to the new server. i would like to check that everything works on the new server before it goes live. so i was wondering of there was a way to check on my local network.. something like 192.168.1.122/?????? is this possible?


    thanks

    kwick
     
  2. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    absolutely, you might have to trick your system into using that IP for a given domain though.
    On Windows uhm dunno something in C:\windows\system32\drivers\etc\hosts and most linux dists /etc/hosts
    there should be some examples in there already but usually you set
    192.168.1.122 domain.com
    192.168.1.122 www.anotherdomain.cool

    should work, if it doesn't uhm you might need to temporarily! set the listen-ip for a website to that IP, depending on the setup
     
    kwickcut likes this.
  3. kwickcut

    kwickcut Member HowtoForge Supporter

    that does not work already tried thanks for the reply
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    I use it daily and it should work on any system, no matter if windows, mac or Linux. Most likely you use a wrong IP then in the hosts file or in the website settings.
     
    ztk.me likes this.
  5. kwickcut

    kwickcut Member HowtoForge Supporter

    this is what i have done
    Code:
     vi /etc/apache2/ports.conf 
    change listen from 80 to 8000
    Code:
     vi etc/apache2/site-available/mysite.com.vhost
    change listen from 80 to 8000
    Code:
     vi etc/apache2/site-available/ispconfig.conf 
    change NameVirtualHost *:80 to 8000

    then i restarted apache
    Code:
    /etc/init.d/apache2 restart
    i have tried server ip
    192.168.1.122/mysite.com
    This site can’t be reached
    192.168.1.122 refused to connect.

    192.168.1.122/www.mysite.com
    This site can’t be reached
    192.168.1.122 refused to connect.

    192.168.1.122:8000 this takes me to the Apache2 Ubuntu Default Page it works page. same as is i entered 192.168.1.122
    i have uploaded an html file to the website folder index.html it just hello and welcome to the site. i can not load this page

    am i missing something?

    thanks
     
  6. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Why do you need to do that when you simply need to add your server ip and website domain name in the hosts file in your pc and then type the said domain in any of its browsers as advised before you above?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    What you did is not what @ztk.me recommended you to do and what I and @ahrasis confirmed to be working fine.

    1) undo all hanges that you made in the vhost files.
    2) Edit the hosts file on your desktop as suggested.
    3) Enter http://yourdoamin.tld in the web browser to access the site and not the IP plus some kind of folder.
     
    Last edited: Oct 6, 2017
    kwickcut likes this.
  8. kwickcut

    kwickcut Member HowtoForge Supporter

    thank you i miss understood what you were saying but understand now thanks

    i have done the following on my windows 7 laptop
    1. Click Start > All Programs > Accessories.
    2. Right-click Notepad and select Run as administrator.
    3. Click Continue on the Windows needs your permission UAC window.
    4. When Notepad opens, click File > Open.
    5. In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
    6. Click Open.
    7. Make the necessary changes to the file.
    8. Click File > Save to save your changes.
    this was the output

    127.0.0.1 localhost

    so i added

    127.0.0.1 localhost
    192.168.1.122 mysite.com
    192.168.1.122 www.mysite.com

    then i saved the file went into my browser and entered
    http://mysite.tld
    this is what i am getting
    This site can’t be reached
    mysite.tld refused to connect.

    when you speak about folders what exactly are you talking about should i be using the website directory /var/www/clients/client0/web1

    or do i need to do what @ztk.me stated. and if so wear do i make that change my router and server?
    if it doesn't uhm you might need to temporarily! set the listen-ip for a website to that IP

    sorry for not understanding i think i need to take a class on this stuff.. what would you recommend for a novices like me?

    thanks again for all the help

    kwick
     
  9. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    first please double check the hosts file has been saved correctly by reopening it.
    however "refused to connect" indicates either you are using the wrong IP or you can't connect to the server with the given IP,
    if it is the correct ip ( e.g. you can start->run->cmd-> ping <ip> it ) the webserver might not listen on the IP
    if ping doesn't work, the network configuration on the server needs to be changed to add the local network ip aswell.

    for the webserver to listen on your 192. IP aswell, make sure it is actually listening on that, this could be achieved by checking your
    /etc/apache2/ports.conf containing
    Code:
    # If you just change the port or add more ports here, you will likely also
    # have to change the VirtualHost statement in
    # /etc/apache2/sites-enabled/000-default.conf
    
    Listen 80
    
    <IfModule ssl_module>
    Listen 443
    </IfModule>
    
    <IfModule mod_gnutls.c>
    Listen 443
    </IfModule>
    
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
    # NameVirtualHost *:80
    # NameVirtualHost *:443
    
    if you added the 192. IP while the webserver was running, you may need to restart apache by issueing
    Code:
    service apache2 restart
    if you had to change the ports.conf aswell.

    if that still doesn't work you can try adding the 192. IP to System > Server IP Adresses in ISPConfig and change the IP for the website accordingly.

    If this still doesn't work ... uhm I'd need to grab a big cup of coffee I guess
     
    kwickcut likes this.
  10. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    ah yeah, it could aswell be a caching issue, too
    close your browser,
    check ping command wether it returns the desired IP when pinging the domain, if not flush your dnscache ( however it is done on windows, I usually google that )
    and start your browser again
     
  11. kwickcut

    kwickcut Member HowtoForge Supporter

    thank you it was the /etc/apache2/ports.conf i needed to edit it and restart apache2 now i can land on the apache2 page by using
    http://mysite.tld
    http://www.mysite.tld

    but i can not load the index.html that says hello welcome to your site
    thanks again for your help
     
  12. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    did you by chance allow wildcard IP?
    System > Server Config > Web > Enable IP wildcard (*)
    Disable that and make sure every website is using a proper IP-Adress instead of the asterisk
     
    kwickcut likes this.
  13. kwickcut

    kwickcut Member HowtoForge Supporter

    thank you THANK you THANK YOU

    that was it removed the check mark and now i see the page you are the best..

    now could you recommend linux for dummies
     
  14. ztk.me

    ztk.me Well-Known Member HowtoForge Supporter

    unfortunally I learned kinda everything by try'n'error'readingdocs'google since I was a kid so uhm never actually read any books - there are few lectures I know of who are not that bad but uhm unfortunally german lectures, dunno if hat would help :(

    But glad it workes now, if you add apache vhost config / namevirualhost to the list what to be researched you already made the first step / you learned something already, just cause yourself new problems to solve :) And always, take your time to rethink about every little aspect


    edit: in this context I mean "to google" as in research, google wasn't there when I was a kid :D
     
    ahrasis and kwickcut like this.

Share This Page