Block websites in Debian - linux

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".

Related

Nuxt subdomain only works with localhost

I need to get subdomain on Nuxt. So I use const domain = window.location.hostname and it works perfectly fine when for exemple I try exemple.localhost:3000
But when I try to change the hosts and try to do exemple.mydomain:3000 my browser can't find it while mydomain:3000 works
nuxt launch script as dev:
nuxt --hostname 'mydomain' --port 3000
and etc/hosts :
127.0.0.1 localhost mydomain mydomain.local
# 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
nuxt.config.js :
server: {
host: 'mydomain'
port: 3000
}

IIS host name binding gives a 404 error, works when empty

I have a somewhat weird problem on my IIS server, running a ASP.NET Core application.
The server runs correctly when there is a binding with an empty host name (wildcard). The localhost and domain name can access it correctly using this method. When putting a localhost binding only, it works on localhost, however, when putting my host name (www.mywebsite.com, mywebsite.com), accessing the website using the domain name results in an error 404.
I tried to configure my hosts file as far as I can:
127.0.0.1 localhost
::1 localhost
127.0.0.1 mywebsite.com
127.0.0.1 www.mywebsite.com
::1 mywebsite.com
::1 www.mywebsite.com
(obviously replace mywebsite.com by the real domain name)
Thanks!

Setting up multiple virtual hosts in Apache2

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?

Running DNS Server to circumvent NAT-Loopback issue

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.

.htaccess password protection allows 127.0.0.1 but not localhost

I'm attempting to password protect my public folder so that anyone trying to access externally is prompted to enter a password but not locally. So far I have got it to work using 127.0.0.1 but not localhost. Obviously I COULD just used the ip address but it's more the fact I want to know why it doesn't work. I don't like to be defeated!
#Enable Password Protection
AuthName "Password Protected Server"
AuthType Basic
AuthUserFile c:\xampp\apache\security\.htpasswd
Require valid-user
Order allow,deny
Allow from localhost
Allow from 127.0.0.1
Satisfy Any
My code so far is an accumulation of:
http://www.groovypost.com/howto/how-to/htaccess-password-protect-apache-website-security/
htaccess password protect but not on localhost
I'm running XAMPP 1.7.3 on Windows 7, in case that helps.
Any assistance would be greatly appreciated!
Sounds like an IPv6 issue. When you're connecting to the site with 127.0.0.1, Apache sees the request as coming from the IPv4 localhost (127.0.0.1). But, when connecting to localhost, Apache sees the request as coming from the IPv6 localhost (::1).
If this is the problem, you should be able to solve it by replacing the Allow from localhost line with a Allow from ::1 line.

Resources