LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2013, 08:20 PM   #1
rj_gtx
LQ Newbie
 
Registered: Jan 2013
Posts: 13

Rep: Reputation: Disabled
How to deny access to https youtube,facebook


Hello, Im having a problem on blocking https access to youtube and facebook....
Im running squid proxy in transparent mode....
they say you cant block https on certain sites like youtube and facebook if squid is in transparent mode.

this thread says its possibles using iptables but he didnt posted how..
http://www.linuxquestions.org/questi...-squid-750621/

anybody know how to do it?


heres my IPTABLES:
Quote:
# Generated by iptables-save v1.4.7 on Thu Jan 24 14:24:59 2013
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.100.1:3128
-A POSTROUTING -o eth1 -j MASQUERADE
COMMIT
# Completed on Thu Jan 24 14:24:59 2013
# Generated by iptables-save v1.4.7 on Thu Jan 24 14:24:59 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [26:3295]

-A INPUT -i eth1 -p icmp -m icmp --icmp-type 8 -j DROP
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp --dport 3128 -j ACCEPT
-A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i eth0 -o eth1 -j ACCEPT
-A OUTPUT -p tcp -m tcp --dport 25 -j ACCEPT
COMMIT
# Completed on Thu Jan 24 14:24:59 2013
and my squid.conf:
Quote:
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT

#ACL blocksites
acl blocksites dstdomain "/etc/squid/blockedsites.squid"


#ACL blockkeywords
acl blockkeywords url_regex -i "/etc/squid/blockkeywords.squid"



# Allow Yahoo Messenger
acl YIM_ports port 5050
acl YIM_domains dstdomain .yahoo.com .yahoo.co.jp
acl YIM_hosts dstdomain scs.msg.yahoo.com cs.yahoo.co.jp
acl YIM_methods method CONNECT
http_access allow YIM_methods YIM_ports YIM_hosts
http_access allow YIM_methods YIM_ports YIM_domains


#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost

# Deny access to blocksites ACL
http_access deny blocksites

# Deny access to blockkeywords ACL
http_access deny blockkeywords


http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128 intercept

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 32 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

# set visible_hostname (specify hostname)
visible_hostname squid.prototype.commm
 
Old 01-26-2013, 03:24 AM   #2
darthaxul
Member
 
Registered: Aug 2008
Distribution: Devuan; Gentoo; FreeBSD
Posts: 239

Rep: Reputation: 19
talkblock

have you tried hosts file for local block? or you could create dns entry pointing to 404.
 
Old 01-26-2013, 04:45 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Question, do you want to block youtube and facebook or just ssl access to those sites?
 
Old 01-27-2013, 09:36 PM   #4
rj_gtx
LQ Newbie
 
Registered: Jan 2013
Posts: 13

Original Poster
Rep: Reputation: Disabled
i want to block both http and https access to those site...Ive already managed to block only http.. Now users found a way to access and that's through https..
 
Old 01-27-2013, 09:37 PM   #5
rj_gtx
LQ Newbie
 
Registered: Jan 2013
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by darthaxul View Post
have you tried hosts file for local block? or you could create dns entry pointing to 404.
kindly tell me how to do that. Please...
 
Old 01-28-2013, 04:59 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Why not use nslookup to determine the IP addresses of Youtube and facebook and block the IP addresses in iptables. Or add the domains to the acl lists for squid.
According to your configuration, the block list is at
acl blocksites dstdomain "/etc/squid/blockedsites.squid"

Have entries like
.youtube.com
.facebook.com
 
Old 01-28-2013, 09:33 PM   #7
rj_gtx
LQ Newbie
 
Registered: Jan 2013
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jschiwal View Post
Why not use nslookup to determine the IP addresses of Youtube and facebook and block the IP addresses in iptables. Or add the domains to the acl lists for squid.
According to your configuration, the block list is at
acl blocksites dstdomain "/etc/squid/blockedsites.squid"

Have entries like
.youtube.com
.facebook.com
it didn't work on squid
 
Old 01-28-2013, 11:00 PM   #8
routers
Member
 
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 787
Blog Entries: 6

Rep: Reputation: 75
Could you try edit the /etc/hosts

127.0.0.1 facebook.com
127.0.0.1 youtube.com
 
Old 01-28-2013, 11:52 PM   #9
rj_gtx
LQ Newbie
 
Registered: Jan 2013
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by routers View Post
Could you try edit the /etc/hosts

127.0.0.1 facebook.com
127.0.0.1 youtube.com
what am i gonna suppose to do with this?add it to the host? or to the host deny?
 
Old 01-29-2013, 12:03 AM   #10
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
Adding the entry in your hosts could able to block facebook & youtube access on Just on the pc which you had made host entry .You want to block facebook & youtube on all user pc configure squid .



Make a entry in squid configuration file to block facebook & youtube.

acl badsite dstdomain .facebook.com .youtube
http_reply_access deny badsite
http_access deny CONNECT badsite
 
Old 01-29-2013, 12:43 AM   #11
rj_gtx
LQ Newbie
 
Registered: Jan 2013
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by arun5002 View Post
Adding the entry in your hosts could able to block facebook & youtube access on Just on the pc which you had made host entry .You want to block facebook & youtube on all user pc configure squid .



Make a entry in squid configuration file to block facebook & youtube.

acl badsite dstdomain .facebook.com .youtube
http_reply_access deny badsite
http_access deny CONNECT badsite
thank you for this but, it didnt work at all.... im running squid in transparent mode...
 
Old 02-01-2013, 08:55 PM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Editing /etc/hosts will only redirect the addresses on the proxy device.
 
Old 02-01-2013, 08:57 PM   #13
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Did you edit /etc/squid/blockedsites.squid?
 
Old 02-02-2013, 12:17 AM   #14
hamlindsza
Member
 
Registered: Aug 2012
Distribution: Debian, CentOS
Posts: 74

Rep: Reputation: Disabled
Quote:
# Squid normally listens to port 3128
http_port 3128 intercept
From the above config. it seems your are trying to use squid as a transparent proxy.

Quote:
-A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.100.1:3128
From the this iptable rule your are redirecting only port 80 ie. HTTP traffic to the squid proxy, hence the HTTPS traffic isn't getting redirected to Squid.

Redirecting HTTPS traffic could get a bit tricky, you might need ure users to import certificates in their browsers before you do that.
 
Old 02-22-2013, 01:04 AM   #15
rj_gtx
LQ Newbie
 
Registered: Jan 2013
Posts: 13

Original Poster
Rep: Reputation: Disabled
i still cant find a way to do this...some say a script would do the trick... anybody got one?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] iptable rules to block https://www.facebook.com mandyapenguin Linux - Newbie 21 11-18-2015 11:35 PM
Most YouTube videos and Facebook games won't play. LinuxLiker Linux - Software 13 04-19-2012 09:54 AM
Try to block https://facebook.com but cannot able to do this yet tanin007 Linux - Software 10 01-13-2012 09:09 AM
[SOLVED] how to deny block https sites for some users Winanjaya Linux - Security 10 12-01-2009 12:36 AM
deny access to youtube.com 7mza Linux - Networking 3 01-20-2009 05:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration