I'm trying to setup a new site using apache in debian
BUt when I'm acessing the public domain (e.g. http://31.128.74.178:81/) I get nothing in the browser
The site contains a wordpress blog
This is the website .conf file
<VirtualHost *:81>
ServerAdmin admin#domain.com
DocumentRoot /var/www/apoint/wordpress
ServerName domain.com
<Directory /var/www/apoint/wordpress>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/domain.com_error.log
CustomLog ${APACHE_LOG_DIR}/domain.com_access.log combined
</VirtualHost>
This is the Google cloud 81 port configuration
How can i fix this?
A few scenarios you can be running into:
You don't have the proper firewall rule to allow inbound connections in port 81. If you have UFW (Uncomplicated Firewall) installed in your server, the easiest way to check this is with the command below:
sudo ufw status numbered
You should get an output like this one:
Status: active
To Action From
-- ------ ----
[ 1] OpenSSH ALLOW IN Anywhere
[ 2] 81/tcp ALLOW IN Anywhere
[ 3] OpenSSH (v6) ALLOW IN Anywhere (v6)
[ 4] 81/tcp (v6) ALLOW IN Anywhere (v6)
If you don't see port 81 listed, then you need to allow it with the following command:
sudo ufw allow 81/tcp
In case you don't have UFW installed, here you can find a guide on how to install and enable it. Please be very cautious when enabling it, since you could lose access to the server [1].
As pointed out by John Hanley, you don't have a listener configured in the /etc/apache2/ports.conf file; in that case, you just need to add the following line in the mentioned file:
Listen 81
[1] https://linuxize.com/post/how-to-setup-a-firewall-with-ufw-on-debian-10/
Related
So I set up a few virtual hosts with unique urls and they work just fine on the desktop. However, when I connect a mobile device on the network, it can't seem to access anything properly but the default localhost virtualhost and that's only when it's the only virtualhost I have up.
My setup and coding is pretty much this except with a different site title
wamp server 3.0 virtual host on another device
and while that solution redirects me to my unique url, it has a lack of images on a default wordpress website.
Has anyone managed to get mobile devices fully accessing links other than on localhost?
Since I posted the answer you referenced, I have decided upon a simpler solution.
What the actual problem is
Because we cannot fiddle with the configuration of a phone like we can with a PC, the phone can never find the domain name we create in our Virtual Host definition on the Server machine, because it does not exist in any DNS Server for it to locate the IP Address in, and a DNS Server is the only place a phone can look, unless it is jail broke.
If you wanted to access one of your Virtual Hosts domains from another PC you could just add a line like this into the HOSTS file on the other PC like this.
192.168.0.10 example.local
But you cannot do that on a phone/tablet.
What Apache expects to be able to asssociate a request to a Vhost
When we create an Apache Virtual Host, we are actually telling Apache to look at the domain name on the incoming connection and match that domain name to a ServerName that exists in one of our multiple Virtual Hosts definitions.
But if we use for example example.local as our virtually hosted domain when we attempt to connect to that from our phone, the phone does a DNS Lookup and does not find that domain and therefore cannot get its ip address.
The simplest way to get round this is:
Assuming we do not have access to adding record to a DNS Server we have to come up with a different solution.
The simplest of these is to use the IP Address of the PC running the WAMPServer(Apache) server and a specific port number. So thats a different port number for each of our sites we want to use from a phone.
So how do we do this
Add the new listening port to httpd.conf like so after the 2 existing Listen statements
WAMPServer 3: Do this using the menus, not by doing a manual edit on httpd.conf
right click wampmanager-> Tools -> Add listen port for Apache
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
Listen [::0]:80
Listen 0.0.0.0:8000
Listen [::0]:8000
Suggested httpd-vhosts.conf file
#
# Virtual Hosts
#
# Always keep localhost, and always first in the list
# this way a ramdom look at your IP address from an external IP
# maybe a hack, will get told access denied
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# The normal Vhost definition for one of our sites
<VirtualHost *:80>
ServerName example.local
DocumentRoot "c:/websrc/example/www"
<Directory "d:/websrc/example/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
# Access example.dev from phone for testing
<VirtualHost *:8000>
ServerName example.local
DocumentRoot "c:/websrc/example/www"
<Directory "d:/websrc/example/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
# assuming yoursubnet is 192.168.0.?
# allow any ip on your WIFI access
Require ip 192.168.0
</Directory>
</VirtualHost>
Restart Apache from wampmanager after completing these edits.
Now you test this from the WAMPServer PC by using the ServerName i.e example.dev and from the phone using the ip of the PC running WAMPServer with the port number i.e. 192.168.0.10:8000
Apache will find the correct code to serve from both requests.
If you want more than one Virtual Host to be accessible from your phone you just duplicate this idea and change the port number for each new site, lets say you would use 8001,8002,8003 etc. For as many sites as you want to access.
You may also have to amend your firewall to allow access on http on port 8000, or whatever port you pick to use
I have an apache web server setup on my development machine (macos sierra). The configuration I had setup has been working fine for months, but for some reason it decided to stop working today. I have to include the port number (i.e. mysite.local.com:8080) for any locally hosted site I want to navigate to. If I leave off the port number I get ERR_EMPTY_RESPONSE in the browser. The config test is passing with no errors. I haven't upgraded or changed anything on this machine (that I can recall) that would cause virtual hosts to stop working. Can anyone suggest a way to pin down what the issue is here?
FYI
sudo apachectl -S produces
VirtualHost configuration:
*:87 bto.local.tura.com (/private/etc/apache2/sites-enabled/bto.local.tura.com.conf:2)
*:8080 is a NameVirtualHost
default server mr.local.tura.com (/private/etc/apache2/sites-enabled/mr.local.tura.com.conf:1)
port 8080 namevhost mr.local.tura.com (/private/etc/apache2/sites-enabled/mr.local.tura.com.conf:1)
port 8080 namevhost optics.local.tura.com (/private/etc/apache2/sites-enabled/optics.local.tura.com.conf:1)
*:85 overstock.local.tura.com (/private/etc/apache2/sites-enabled/overstock.local.tura.com.conf:1)
*:86 static.local.tura.com (/private/etc/apache2/sites-enabled/static.local.tura.com.conf:1)
My httpd.conf:
Listen 8080
Listen 85
Listen 86
Listen 87
...
ErrorLog "/var/log/apache2/error.log"
...
Include /private/etc/apache2/sites-enabled/*.conf
An example of a vhhost config file:
<VirtualHost *:85>
ServerName overstock.local.tura.com
DocumentRoot /usr/local/web/overstock
ErrorLog /var/log/apache2/overstock.local.tura.com.error.log
CustomLog /var/log/apache2/overstock.local.tura.com.access.log "combined"
<Directory "/usr/local/web/overstock">
Order Deny,Allow
Deny from all
Allow from all
Options -Indexes +FollowSymLinks
</Directory>
LogLevel emerg
</VirtualHost>
I think you should add
Listen 80
try by changing deny from none in place of deny from all
what are errors from /var/log/apache2/error.log ,paste the content of error.log
I just installed LAMP on my Ubuntu machine, and it works fine when I access it. I want to add a virtual host on another port, port 1337, that goes to the directory /var/www/flag-1/. In order to do this, I take the following steps:
cd /etc/apache2/sites-available/
Created a file flag-1.conf
Added contents:
<VirtualHost *:1337>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/flag-1/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
At the top of /etc/apache2/ports.conf, after Listen 80, added Listen 1337
Enabled the vhost site by doing a2ensite flag-1.conf
Reloaded apache service apache2 restart
When I access the site with port 1337, it just loads indefinitely. The default port still works fine, and I don't have UFW enabled. No errors, nothing in access.log or error.log is outstanding.
Any help is appreciated. Thanks!
Figured it out -- I was using Google Cloud Platform and they blocked port 1337, I just had to manually allow TCP through it.
If you're wondering, the command was
gcloud compute firewall-rules create allow-port-1337 --allow tcp:1337 --description="Allow port 1337 to be accessed"
I have several named virtual hosts on the same apache server, for one of the virtual host I need to ensure only a specific set of IP addresses are allowed to access.
Please suggest the best way to do this. I have looked at mod_authz_hosts module but it does not look like I can do it inside virtual host.
The mod_authz_host directives need to be inside a <Location> or <Directory> block but I've used the former within <VirtualHost> like so for Apache 2.2:
<VirtualHost *:8080>
<Location>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
...
</VirtualHost>
Reference: https://askubuntu.com/questions/262981/how-to-install-mod-authz-host-in-apache
For Apache 2.4, you would use the Require IP directive. So to only allow machines from the 192.168.0.0/24 network (range 192.168.0.0 - 192.168.0.255)
<VirtualHost *:80>
<Location />
Require ip 192.168.0.0/24
</Location>
...
</VirtualHost>
And if you just want the localhost machine to have access, then there's a special Require local directive.
The local provider allows access to the server if any of the following conditions is true:
the client address matches 127.0.0.0/8
the client address is ::1
both the client and the server address of the connection are the same
This allows a convenient way to match connections that originate from the local host:
<VirtualHost *:80>
<Location />
Require local
</Location>
...
</VirtualHost>
If you are using apache 2.2 inside your virtual host you should add following directive (mod_authz_host):
Order deny,allow
Deny from all
Allow from 10.0.0.1
You can even specify a subnet
Allow from 10.0.0
Apache 2.4 looks like a little different as configuration.
Maybe better you specify which version of apache are you using.
In Apache 2.4, the authorization configuration syntax has changed, and the Order, Deny or Allow directives should no longer be used.
The new way to do this would be:
<VirtualHost *:8080>
<Location />
Require ip 192.168.1.0
</Location>
...
</VirtualHost>
Further examples using the new syntax can be found in the Apache documentation: Upgrading to 2.4 from 2.2
I'm setting up a dedicated server with multiple virtual hosts. The DNS is registered correctly...
$ ping mydomain.com
$ ping 8.8.8.8 (for example)
Both return the IP address as expected and it's correct.
The last line of my httpd.conf file is:
Include /etc/httpd/sites-enabled/
And the contents of mydomain.com.conf (in the above folder) are:
<VirtualHost 8.8.8.8:80>
ServerName mydomain.com
ServerAdmin jongosi#mydomain.com
# Indexes + Directory Root
VirtualDocumentRoot /var/www/html/mydomain.com
DocumentRoot /var/www/html/mydomain.com
<Directory "/var/www/html/mydomain.com">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I suspected that the firewall was interfering with the access so I have disabled it with:
$ /etc/init.d/iptables stop
The server is running CentOS 6 64-bit with the latest LAMP stack.
Trying to go to the address http://www.mydomain.com/ or the IP address in browser both result in eventual time-out. Any suggestions would be helpful. Thank you!
EDIT 1
Running apachectl -S returns...
VirtualHost configuration:
8.8.8.8:80 mydomain.com (/etc/httpd/sites-enabled/mydomain.com.conf:6)
Syntax OK
EDIT 2
Following the request in Chrome's inspector returns a 204 header response.
204 No Content
The server successfully processed the request, but is not returning any content.
Thanks.
SOLVED
My hosting provider had configured their hardware firewall to only allow traffic through on port 22 (SSH). Why on earth would I NOT want traffic on my WEBSITE.
$_hosting_provider = "In.sane";