stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Testing website from local network

Thu Feb 27, 2020 12:51 pm

I have a website www.stockton.co.za working fine from the internet but as I am altering it I wish to access it from my internal network but cannot.
If, from my development machine, I browse to 192.168.0.100/stockton I get a 404 496 error whereas I am sure if you try you can access it.
/var/www/html/stockton houses the website on 192.168.0.100

User avatar
rpdom
Posts: 16383
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Testing website from local network

Thu Feb 27, 2020 1:06 pm

I get a 404 Not Found when following your link. Does the file index.shtml exist?

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Thu Feb 27, 2020 3:46 pm

Were you using http://stockton.co.za ? or http://stockton.co.za/lcars ? The shtml does exist.

User avatar
rpdom
Posts: 16383
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Testing website from local network

Thu Feb 27, 2020 4:20 pm

stockton wrote:
Thu Feb 27, 2020 3:46 pm
Were you using http://stockton.co.za ? or http://stockton.co.za/lcars ? The shtml does exist.
Now when I try, the first of those links gives me an "Authorisation Required" page and the second link gives a "Not Found". I clicked on the link in your first post earlier.

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Thu Feb 27, 2020 4:32 pm

That is interesting as stockton.co.za/lcars should have asked for authorization and if you clicked on the right of that screen you should have got further.
On the other hand another test has successfully got to stockton.co.za but not stockton.co.za/lcars

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Thu Feb 27, 2020 5:08 pm

stockton.co.za should now work correctly.

epoch1970
Posts: 4492
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Testing website from local network

Thu Feb 27, 2020 5:12 pm

2006-2020 :)
Seems to be working from the internet.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

hvdwolf
Posts: 16
Joined: Sun Nov 12, 2017 4:29 pm

Re: Testing website from local network

Thu Feb 27, 2020 7:02 pm

Which webserver are you using? Apache or nginx?

If Apache, to which address is your server listening in virtualhost?

Only to stockton.co.za:80 or also to 192.168.0.100:80?

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Fri Feb 28, 2020 7:08 am

Please tell me how I make it listen to both stockton.co.za:80(which is what it currently does) and 192.168.0.100:80?

tpyo kingg
Posts: 809
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Testing website from local network

Fri Feb 28, 2020 7:13 am

Make the one a name-based virtual host and the other an IP-based virtual host. For Apache2, if that is what you are using, the authoritative guides would be at the project web site:

http://httpd.apache.org/docs/2.4/vhosts/name-based.html

http://httpd.apache.org/docs/2.4/vhosts/ip-based.html

Give them separate configuration files.

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Fri Feb 28, 2020 7:16 am

Thank you, I tried that but that just gets me to the router not the server. I set up sites-available and sites-enabled and ran a2ensite and /etc/init.d/apache2 restart

User avatar
DougieLawson
Posts: 37725
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Testing website from local network

Fri Feb 28, 2020 8:32 am

stockton wrote:
Fri Feb 28, 2020 7:08 am
Please tell me how I make it listen to both stockton.co.za:80(which is what it currently does) and 192.168.0.100:80?
What "Listen" directive is in your Apache2 config?
By default Apache2 should listen to INADDR_ANY (0.0.0.0) and not be bound to a specific interface.

https://httpd.apache.org/docs/2.4/bind.html
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Fri Feb 28, 2020 8:51 am

I have altered my ports.conf from Listen 80 to Listen stockton.co.za:80 and on the next line Listen 192.168.0.100:80 and did a graceful restart but I still get to the router when attempting local connection.

User avatar
DougieLawson
Posts: 37725
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Testing website from local network

Fri Feb 28, 2020 8:54 am

stockton wrote:
Fri Feb 28, 2020 8:51 am
I have altered my ports.conf from Listen 80 to Listen stockton.co.za:80 and 192.168.0.100:80 and did a graceful restart but I still get to the router when attempting local connection.
Change it back.

Do the stockton.co.za stuff in a VirtualHost.

Code: Select all

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/za/co/stockton # CHANGE ME
    Options +Includes -Indexes +FollowSymlinks +SymLinksIfOwnerMatch
    ServerName stockton.co.za
</VirtualHost>
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Fri Feb 28, 2020 9:14 am

Dougie I fail to understand your recommendations. I have
<VirtualHost stockton.co.za:80
ServerName www.stockton.co.za
ServerAdmin [email protected]
DocumentRoot /var/www/html/stockton
ServerAlias stockton.co.za
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include conf-available/serve-cgi-bin.conf
</VirtualHost>

and

<VirtualHost 192.168.0.100:80>
ServerName www.stockton.co.za
ServerAdmin [email protected]
DocumentRoot /var/www/html/stockton
ServerName 192.168.0.100
ServerAlias 192.168.0.100
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include conf-available/serve-cgi-bin.conf
</VirtualHost>

Please explain.

stockton
Posts: 130
Joined: Mon Aug 24, 2015 6:06 am
Location: South Africa
Contact: Website

Re: Testing website from local network

Fri Feb 28, 2020 2:04 pm

It now appears to be working for me. If I am correct in that, the solution on my machine is as follows:-
I am running Rasbian and therefore the Apache configuration follows the Debian way.
Apache needs to listen to port 80 both as an external link(DNS) & internal link(IP).
I achieved this after much help from all the above by altering /etc/apache2/ports.conf to listen to both via
Listen stockton.co.za:80
Listen 192.168.0.100:80

and then creating a /etc/apache2/sites-available for 192.168.0.100 for I already had one for stockton.co.za
Each of their virtualhost followed the following convention <VirtualHost stockton.co.za:80> and <VirtualHost 192.168.0.100:80> and then a link from sites-enabled to both of these, followed by restarting the Apache server.

Now guys if any of the above is wrong please correct me.
All that leaves me to say is thank you one and all.

User avatar
DougieLawson
Posts: 37725
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Testing website from local network

Fri Feb 28, 2020 10:06 pm

You can change the two listen directives to a single

Code: Select all

Listen 80
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Networking and servers”