Advertisement
Guest User

Untitled

a guest
Mar 4th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #!/bin/sh
  2. PROXY_USER=sam
  3. PROXY_PASS=armardi
  4. PROXY_PORT=3128
  5. # Clear the repository index caches
  6. yum clean all
  7. # Update the operating system
  8. yum update -y
  9. # Install httpd-tools to get htpasswd
  10. yum install httpd-tools -y
  11. # Install squid
  12. yum install squid -y
  13. # Create the htpasswd file
  14. htpasswd -c -b /etc/squid/passwords $PROXY_USER $PROXY_PASS
  15. # Backup the original squid config
  16. cp /etc/squid/squid.conf /etc/squid/squid.conf.bak
  17. # Set up the squid config
  18. cat << EOF > /etc/squid/squid.conf
  19. auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/passwords
  20. auth_param basic realm proxy
  21. acl authenticated proxy_auth REQUIRED
  22. http_access allow authenticated
  23. forwarded_for delete
  24. http_port 0.0.0.0:$PROXY_PORT
  25. EOF
  26. # Set squid to start on boot
  27. # Set squid to start on boot
  28. chkconfig squid on
  29. # Start squid
  30. /etc/init.d/squid start
  31. # Set up the iptables config
  32. cat << EOF > /etc/sysconfig/iptables
  33. *filter
  34. :INPUT ACCEPT [0:0]
  35. :FORWARD ACCEPT [0:0]
  36. :OUTPUT ACCEPT [0:0]
  37. -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  38. -A INPUT -p icmp -j ACCEPT
  39. -A INPUT -i lo -j ACCEPT
  40. #######################################################
  41. # BEGIN CUSTOM RULES
  42. #######################################################
  43. # Allow SSH from anywhere
  44. -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
  45. # Allow squid access from anywhere
  46. -A INPUT -m state --state NEW -m tcp -p tcp --dport $PROXY_PORT -j ACCEPT
  47. #######################################################
  48. # END CUSTOM RULES
  49. #######################################################
  50. -A INPUT -j REJECT --reject-with icmp-host-prohibited
  51. -A FORWARD -j REJECT --reject-with icmp-host-prohibited
  52. COMMIT
  53. EOF
  54. # Restart iptables
  55. /etc/init.d/iptables restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement