Access Apache Site via URL

Soldato
Joined
28 Sep 2008
Posts
14,158
Location
Britain
Doing my nut in!

Got an Azure VM running Ubuntu and Apache2. Its on 10.0.0.1 (within an Azure subnet).

I can access the webpage via 10.0.0.1 all day long.

I've created a /etc/apache2/sites-available/myinternal.domain.conf with:


Code:
<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html
  ServerName myinternal.domain
  ErrorLog /var/log/apache2/error.log
  CustomLog /var/log/apache2/.access.log combined
</VirtualHost>


I've setup DNS locally within the environment so that 10.0.0.1 points to myinternal.domain and nslookup supports that, but yet, nothing.

Grrrr. Any ideas? I see a hosts file in apache2 which I could try I guess?
 
Permabanned
Joined
9 Aug 2008
Posts
35,707
I moved away from Apache2 to Caddy as I had issues with SSL and certs. I installed webmin to manage sites as the front end was great. You could install the latest version of Webmin to help you manage Apache2.

I take it when you ping "myinternal.domain" you get the IP address of the server? So the DNS is pointing to that web server? When I set up VHOSTS I had this same issue as you but using webmin did resolve this for me.

This is my own instructions to a working webmin install.

Code:
-- Webmin --
sudo nano /etc/apt/sources.list
deb http://download.webmin.com/download/repository sarge contrib
sudo wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
sudo apt-get update
sudo apt-get install webmin
-- Webmin --


https://www.digitalocean.com/commun...t-up-apache-virtual-hosts-on-ubuntu-14-04-lts

Code:
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Just noticed something! Did you enable the new conf file with this command?...

01) "sudo a2ensite myinternal.domain.conf"
02) then > "sudo service apache2 restart"
 
Last edited:
Associate
Joined
17 Nov 2007
Posts
107
Sounds like a port or Apache virtual host issue. If nslookup resolves the correct IP address (and vice versa with ping) then the routing is OK, so it's something on the level above that. Check the Apache error logs for any mention of access.
 
Soldato
OP
Joined
28 Sep 2008
Posts
14,158
Location
Britain
I moved away from Apache2 to Caddy as I had issues with SSL and certs. I installed webmin to manage sites as the front end was great. You could install the latest version of Webmin to help you manage Apache2.

I take it when you ping "myinternal.domain" you get the IP address of the server? So the DNS is pointing to that web server? When I set up VHOSTS I had this same issue as you but using webmin did resolve this for me.

This is my own instructions to a working webmin install.

Code:
-- Webmin --
sudo nano /etc/apt/sources.list
deb http://download.webmin.com/download/repository sarge contrib
sudo wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
sudo apt-get update
sudo apt-get install webmin
-- Webmin --


https://www.digitalocean.com/commun...t-up-apache-virtual-hosts-on-ubuntu-14-04-lts

Code:
<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Just noticed something! Did you enable the new conf file with this command?...

01) "sudo a2ensite myinternal.domain.conf"
02) then > "sudo service apache2 restart"

I've seen Webmin, but not used it yet. Might give that a whirl.

The error I get when trying URL is (Chrome) This site can't be reached. myinternal.domain refused to connect.
 
Soldato
OP
Joined
28 Sep 2008
Posts
14,158
Location
Britain
ok, using webmin under existing virtual hosts shows:

Code:
Handles the name-based server myinternal.domain on address *.
Address Any   Server Name myinternal.domain
Port 80          Document Root /var/www/html

So in my mind, that should be working a treat :D

Except, it isn't
 
Soldato
Joined
24 Sep 2015
Posts
3,852
From whatever client you're running Chrome on, what happens if you open a command prompt and do 'telnet myinternal.domain 80' ? Does it connect (ie, you get a black screen) or do you get an error?
 
Soldato
OP
Joined
28 Sep 2008
Posts
14,158
Location
Britain
From whatever client you're running Chrome on, what happens if you open a command prompt and do 'telnet myinternal.domain 80' ? Does it connect (ie, you get a black screen) or do you get an error?
I ran the PoSH equivalent and got this:

Code:
Client              : System.Net.Sockets.Socket
Available           : 0
Connected           : True
ExclusiveAddressUse : False
ReceiveBufferSize   : 65536
SendBufferSize      : 65536
ReceiveTimeout      : 0
SendTimeout         : 0
LingerState         : System.Net.Sockets.LingerOption
NoDelay             : False

I'm wondering if it's the corporate proxy doing bad things here. That or the fact that chrome forces https now instead of http. Not really sure
 
Soldato
Joined
24 Sep 2015
Posts
3,852
From the Ubuntu box, what IP address gets returned if you ping myinternal.domain? Assuming it's using the same DNS server as your client it should be correct but it's worth checking.

Can you try with something other than Chrome? Try this from PowerShell:

Code:
$WebResponse = Invoke-WebRequest "http://myinternal.domain"
$WebResponse.Content
 
Soldato
OP
Joined
28 Sep 2008
Posts
14,158
Location
Britain
Did you enable the new conf file? (sudo a2ensite myinternal.domain.conf) and then restart the apache service again?

Try another browser to make sure it's not the browser!

Yep, I enabled it (and disabled the default.conf) and restarted both apache, and the server for lols. Tried Chrome and Edge.
 
Soldato
Joined
28 Oct 2006
Posts
12,456
Location
Sufferlandria
The HTML is returned nicely within the PoSH window

The correct HTML from the website? So it's a problem with the browser?

If it's chrome trying to connect over HTTPS as someone suggested before, you probably just need to add another bit to your config file to add port 443 in the same way you already have port 80:
<VirtualHost *:80>

I've never used Apache though so I'm not sure exactly how you'd do that.

You'll also get a certificate error when you do this (unless you've got an SSL certificate for it?) but at least you'll know it works.
 
Soldato
OP
Joined
28 Sep 2008
Posts
14,158
Location
Britain
The correct HTML from the website? So it's a problem with the browser?

If it's chrome trying to connect over HTTPS as someone suggested before, you probably just need to add another bit to your config file to add port 443 in the same way you already have port 80:
<VirtualHost *:80>

I've never used Apache though so I'm not sure exactly how you'd do that.

You'll also get a certificate error when you do this (unless you've got an SSL certificate for it?) but at least you'll know it works.

Correct, I can see the HTML from the site that I would expect to see.

As I say, we use a pac file for Proxy and pretty sure Chrome forces https now, so I suspect that is something to do with it.
 
Back
Top Bottom