EDIT: I HAVE SINCE FIXED IT BY ALLOWING PORT 80 THROUGH UFW (sudo ufw allow 80)(sudo service ufw status verbose)
I've been fiddling with this for a while and can't figure it out, the issue I'm having is that the dev subdomain outputs files of the main server, you can find relevant info attached below.
I have changed my domain to abc.com, and changed the IP.
Yes, the config is enabled, and Apache has been restarted, but I'm still being served the file /var/www/abc.com/public/index.php rather than /var/www/dev.abc.com/public/index.php.
At this point, I've given up due to my lack of Linux + Apache knowledge.
Zone file:
$ORIGIN abc.com.
$TTL 1800
abc.com. IN SOA ns1.digitalocean.com. hostmaster.abc.com. 1467393676 10800 3600 604800 1800
abc.com. 1800 IN NS ada.ns.cloudflare.com.
abc.com. 1800 IN NS neil.ns.cloudflare.com.
abc.com. 1800 IN A XXX.XXX.XXX.XXX
www.abc.com. 1800 IN CNAME abc.com.
dev.abc.com. 1800 IN A XXX.XXX.XXX.XXX
/etc/hosts:
127.0.1.1 ubuntu-512mb-nyc2-01 ubuntu-512mb-nyc2-01
127.0.0.1 localhost
XXX.XXX.XXX.XXX abc.com
XXX.XXX.XXX.XXX www.abc.com
XXX.XXX.XXX.XXX dev.abc.com
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
abc.com.conf:
NameVirtualHost XXX.XXX.XXX.XXX:80
ServerName abc.com
<VirtualHost XXX.XXX.XXX.XXX:80>
ServerName abc.com
ServerAlias www.abc.com
DocumentRoot /var/www/abc.com/public/
</VirtualHost>
<VirtualHost XXX.XXX.XXX.XXX:80>
ServerName dev.abc.com
ServerAlias www.dev.abc.com
DocumentRoot /var/www/dev.abc.com/public/
</VirtualHost>
Try removing 'ServerName abc.com' from below the 'NameVirtualHost' part; it can mess your config
Have you checked the general error log? Maybe the reboot failed because of a misconfiguration?
Related
Soo we bough a domain name with the name of mastergamingteam.eu and we've been trying to make it work, but it does not seem to. I've tried a lot of stuff online, but we still can't connect to the page.
From client side it says DNS_PROBE_FINISHED_NXDOMAIN
We use ubuntu 16.04.6
/etc/apache2/sites-available/000-default.conf:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName mastergamingteam.eu
ServerAlias www.mastergamingteam.eu
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
/etc/hosts(This keeps getting overwritten, this is there by default):
# Generated by SolusVM
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
79.139.56.118 mastergamingteam
Port 80 is enabled by ufw and Listened in apache2
A Record:
mastergamingteam.eu priority:0 TTL:7200 Type:A Value:79.139.56.118
NS Record:
mastergamingteam.eu priority:0 TTL:86400 Type:NS Value:ns1.rackforest.hu
The VPS is hosted by rackforest and bought the domain on their site.
Domain record at registrar has errors in name servers' hostnames.
$whois mastergamingteam.eu
Domain: mastergamingteam.eu
...
Registrar:
Name: PDR Ltd.
Website: https://www.publicdomainregistry.com
Name servers:
sn1.rackforest.hu
sns1.racforest.hu
You should edit record registrar and put ns1.rackforest.hu as the first name server.
Also there is only one NS record for your domain.
$ host -t ns mastergamingteam.eu ns1.rackforest.hu
Using domain server:
Name: ns1.rackforest.hu
Address: 185.43.204.2#53
Aliases:
mastergamingteam.eu name server ns1.rackforest.hu
You should probably have ns2.rackforest.hu as second name server.
ns2.rackforest.hu knows about your domain.
$host mastergamingteam.eu ns2.rackforest.hu
Using domain server:
Name: ns2.rackforest.hu
Address: 79.172.213.19#53
Aliases:
mastergamingteam.eu has address 79.139.56.118
the problem here is:
your domain points nowhere. There are no records for your domain (no A or CNAME or any other relevant records) neither are any nameservers configured.
Make sure to set records, as obviously the domain won't work.
You can check your domain's records yourself here: https://digwebinterface.com/?hostnames=mastergamingteam.eu&type=&ns=resolver&useresolver=8.8.4.4&nameservers=
I try to configure virtual hosts. All I do step by step like here
My config:
root#ubuntu:/etc/apache2/sites-available# cat mmv.com.conf
# create new for [mmv.com]
<VirtualHost *:80>
ServerName www.mmv.com
ServerAdmin webmaster#virtual.host
DocumentRoot /var/www/mmv.com
ErrorLog /var/log/apache2/mmv.com.error.log
CustomLog /var/log/apache2/mmv.com.access.log combined
LogLevel warn
</VirtualHost>
My index.html in root folder
cat /var/www/mmv.com/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Virtual Host Test Page
</div>
</body>
</html>
My /etc/hosts
127.0.0.1 localhost
127.0.1.1 ubuntu
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.125.137 www.mmv.com
Looks like all I did right but if I try to open site www.mmv.com and I see default apache page.
Help me to find where I did mistake.
Thanks!
Try this:
ln -s /etc/apache2/sites-available/mmv.com.conf /etc/apache2/sites-enabled
Then restart your apache server.
Stupid guess: the file is in sites-available, but was it enabled?
If you have debian you can use a2ensite mmv.com, otherwise you have to use ln -s as Kiani advised in ^^^.
I found a solution! That right config:
VirtualHost 192.168.125.138:80>
ServerName www.mmv.com
ServerAlias mmv.com *.mmv.com
ServerAdmin webmaster#mmv.com
DocumentRoot /var/www/www.mmv.com
ErrorLog /var/log/apache2/mmv.com.error.log
CustomLog /var/log/apache2/mmv.com.access.log combined
</VirtualHost>
And in file /etc/hosts have to be this:
192.168.125.138 mmv.com www.mmv.com
First I want to say that I probably read everything that there is on the internet regarding the problem.
And the problem is that I can not access my owncloud over doc.selfhost.eu if I am in the same network. But I can access it from inside the network over its internal IP (192.168.2.200) and from outside the network over doc.selfhost.eu.
My setup:
A home server running Linux Mint 17.2 Cinnamon which is supposed to be for media and to run owncloud.
The server is connected to a Speedport 723v which doesn't support NAT Loopback. Ports 80 and 443 are forwarded and for dynamic DNS I have an account on selfhost.de which I entered in the router settings.
On my Windows 7 machine (which I'm trying to access the server from) I entered 192.168.2.200 (the servers internal IP) as DNS.
In Mint I disabled network manager (in fact I removed it) and I am now using interfaces.
Not a solution would be to change the hosts files of all the clients (on unrooted androids this isn't even possible).
Questions:
What would I have to change to access my owncloud from the internal network over the external IP?
Is it possible to not configure the clients at all? Meaning no entering the servers DNS or changing hosts in the clients for it to work properly.
In the following you can see all the files I fiddled around with and which I think might be relevant.
/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.2.200
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers doc.selfhost.eu 8.8.8.8
/etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
In /etc/dnsmasq.conf this is the only thing I added:
listen-address=127.0.0.1
listen-address=192.168.2.200
address=/doc.selfhost.eu/192.168.2.200
/etc/dnsmasq.d/doc.selfhost.eu (read somewhere to create this)
address=/doc.selfhost.eu/192.168.2.200
/etc/hosts
127.0.0.1 localhost
127.0.1.1 doc-desktop
192.168.2.200 doc.selfhost.eu
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Owncloud settings in
/var/www/owncloud/config/config.php
'trusted_domains' =>
array (
0 => '192.168.2.200',
1 => 'doc.selfhost.eu',
);
Apache configuration
In /etc/apache2/apache2.conf everything is pretty standard. I only added:
ServerName doc-desktop
/etc/apache2/sites-enabled/owncloud.conf. No changes in sites-available, no linking.
<VirtualHost 192.168.2.200:80>
#### Redirect to port 443 ###
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
#### End of Redirection configuration ###
DocumentRoot /var/www/owncloud/
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost 192.168.2.200:443>
####Configuration for SSL #####
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
#### End of SSL Configuration ####
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
DocumentRoot /var/www/owncloud/
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
In case it comes up.
from server:
dig doc.selfhost.eu
; <<>> DiG 9.9.5-3ubuntu0.5-Ubuntu <<>> doc.selfhost.eu
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49046
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;doc.selfhost.eu. IN A
;; ANSWER SECTION:
doc.selfhost.eu. 0 IN A 192.168.2.200
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Oct 26 02:35:15 CET 2015
;; MSG SIZE rcvd: 54
From client inside network (with cygwin):
dig doc.selfhost.eu
; <<>> DiG 9.10.3 <<>> doc.selfhost.eu
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29482
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;doc.selfhost.eu. IN A
;; ANSWER SECTION:
doc.selfhost.eu. 0 IN A 192.168.2.200
;; Query time: 31 msec
;; SERVER: 192.168.2.200#53(192.168.2.200)
;; WHEN: Mon Oct 26 02:37:32 2015
;; MSG SIZE rcvd: 54
I hope this is everything.
Thanks.
... which doesn't support NAT Loopback. ....
What would I have to change to access my owncloud from the internal network over the external IP?
If you insist of using the external IP address from inside then you have to replace the router against a model which supports NAT Loopback (NAT hairpinning or NAT reflection or whatever you call it). There is no way around because connection with the external IP address will go through the router.
Is it possible to not configure the clients at all? Meaning no entering the servers DNS or changing hosts in the clients for it to work properly. ..
You might try to run your own DNS server and tell the clients via DHCP to use this DNS server. This DNS server then could provide the internal IP of your home server. I doubt that this can be done on the router itself but you could probably run DNS and DHCP on your home server and disable DHCP on the router.
For specific question on how to set up DNS and DHCP please head over to superuser.com or serverfault.com since this is off-topic here.
I am trying to block websites using /etc/hosts.
Here is my hosts file.
127.0.0.1 localhost
127.0.1.1 debian.localhost debian
#The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
0.0.0.0 facebook.com
127.0.0.1 https://facebook.com
Since it is not working,Please tell me what is going wrong ?
i think you are trying to block facebook from the host file.Just remove other IPV6 entries from your hosts file. (to make it more readable)
try to add following
127.0.0.1 facebook.com (you don't need to put http in front of the domain name)
NOTE : you can put any address in front of your domain. but it is easy to put 127.0.0.1.
so your computer will try to resolve facebook.com and then query the hosts file first. It will return 127.0.0.1 instead of the actual facebook ip address.
I don't know if it's right, but when I tried doing the same, I had to block many other addresses, since you have many domains that are linked to Facebook.
In my case, I had to add those lines :
127.0.0.1 www.facebook.com
127.0.0.1 facebook.com
127.0.0.1 static.ak.fbcdn.net
127.0.0.1 www.static.ak.fbcdn.net
127.0.0.1 login.facebook.com
127.0.0.1 www.login.facebook.com
127.0.0.1 fbcdn.net
127.0.0.1 www.fbcdn.net
127.0.0.1 fbcdn.com
127.0.0.1 www.fbcdn.com
127.0.0.1 static.ak.connect.facebook.com
127.0.0.1 www.static.ak.connect.facebook.com
And it worked perfectly well, whether on Debian, Ubuntu or Fedora. I guess that when you try to go on Facebook, you must be using a domain other that the simple "facebook.com".
I set Centos 6.3 up on a Rackspace box, using a static IP address (not a FQDN). I will be setting up virtual hosts on this box, and it seems to be working fine, but when I restart the HTTPD server, I get an error message "could not reliably determine the server's fully qualified domain name, using xx.xxx.xx.xx for ServerName" (xx.xxx.xx.xx is the static IP address for the server).
My /etc/hosts has the following in it:
27.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
xx.xxx.xx.xx name-used-for-rackspace
name-used-for-racspace is a name (not a FQDN) I used when I created the server (you have to enter a name).
I assume that I may not have to change anything in /etc/hosts, but what do I put in httpd.conf? right now, I have the following in that file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName localhost
<Directory /var/www/html>
allow from all
Options +Indexes
</Directory>
</VirtualHost>
I also tried setting ServerName to xx.xxx.xx.xx, but I got the same error message.
This error is because you are not using a FQDN. It should not affect the operation of the webserver.
To get rid of the message on startup you'd need to configure your hosts file with the correct domain and IP address. Your httpd.conf should also use the same name (where you have localhost specified).
As long as your server is starting and you don't plan on assigning a domain to your webserver, this error can be ignored.
Example virtual host with FQDN:
<VirtualHost *:80>
ServerName www.domain.net
ServerAlias domain.net *.domain.net
ServerAdmin administrator#domain.net
DocumentRoot "/home/domain/htdocs"
<Directory "/home/domain/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
CustomLog "/home/domain/logs/access-www.log" common
ErrorLog "/home/domain/logs/error-www.log"
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
Example hosts file:
127.0.0.1 localhost localhost.localdomain gentoo1
x.x.x.x gentoo1.domain.net
You need to configure the network connection with your static IP, see reference below. Otherwise, your web server is working, but it's not accessible externally.
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Configuring_IPv4_Settings.html
Then put the static IP in the httpd.conf after server name.