找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 6909|回复: 2

如果在 openwrt 上架设一个缓存服务器

[复制链接]
发表于 2015-4-22 20:53 | 显示全部楼层 |阅读模式
请问有意义吗?
我的恩山、我的无线 The best wifi forum is right here.
发表于 2015-4-23 09:20 | 显示全部楼层
你的目的和用途是什么?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2019-6-12 21:53 | 显示全部楼层
本帖最后由 loveqianool 于 2019-6-12 22:16 编辑

闲着没事还是照网上教程搭了个,使用体验就是经常无缘无故的卡一会儿,这里发一下过程吧。
  1. opkg update && opkg install libustream-openssl ca-bundle ca-certificates luci-app-squid
复制代码
#现在安装的 squid 版本是 3.5.27
#创建缓存目录
  1. mkdir /mnt/squid/cache
复制代码
#设置权限
  1. chmod 777 /mnt/squid
复制代码
#初始化缓存目录
  1. squid -z
复制代码

#自签证书, z.der 需要客户端导入,以便代理 https
  1. openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -extensions v3_ca -keyout z.pem -out z.pem
复制代码
  1. openssl x509 -in z.pem -outform DER -out z.der
复制代码
  1. openssl dhparam -dsaparam -out z.dh 2048
复制代码

#编辑 /etc/config/squid 取消所有注释
  1. config squid 'squid'
  2.         option config_file '/etc/squid/squid.conf'
  3.         option http_port '3128'
  4.         option coredump_dir '/tmp/squid'
  5.         option visible_hostname 'OpenWrt'
  6.         option mime_table '/etc/squid/mime.conf'
  7.         option http_port_options 'intercept'
  8.         option ssldb '/mnt/squid/ssldb'
  9.         option ssldb_options '-M 32MB'
复制代码

#编辑 /etc/squid/squid.conf 或者在 luci 界面 - 服务 - squid - 高级设置 中填入以下配置
  1. #设置路由 ip 及端口和自签证书位置
  2. http_port 192.168.1.233:3131 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=10MB cert=/etc/squid/z.pem capath=/etc/ssl/certs/ cipher=EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:HIGH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS tls-dh=prime256v1:/etc/squid/z.dh options=NO_SSLv2,NO_SSLv3,SINGLE_DH_USE,SINGLE_ECDH_USE

  3. http_port 127.0.0.1:3129 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=10MB cert=/etc/squid/z.pem capath=/etc/ssl/certs/ cipher=EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:HIGH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS tls-dh=prime256v1:/etc/squid/z.dh options=NO_SSLv2,NO_SSLv3,SINGLE_DH_USE,SINGLE_ECDH_USE

  4. https_port 127.0.0.1:3130 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=10MB cert=/etc/squid/z.pem capath=/etc/ssl/certs/ cipher=EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:HIGH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS tls-dh=prime256v1:/etc/squid/z.dh options=NO_SSLv2,NO_SSLv3,SINGLE_DH_USE,SINGLE_ECDH_USE

  5. icp_port 0
  6. digest_generation off
  7. dns_v4_first on
  8. pid_filename /var/run/squid.pid
  9. #cache_effective_user squid
  10. #cache_effective_group proxy
  11. #error_default_language zh-cn
  12. icon_directory /usr/share/squid/icons
  13. #visible_hostname z_Squid
  14. cache_mgr <a href="mailto:z@qq.com">z@qq.com</a>
  15. logfile_daemon /dev/null
  16. access_log /var/squid/access.log
  17. cache_log /var/squid/cache.log
  18. cache_store_log none
  19. netdb_filename /var/squid/netdb.state
  20. #sslcrtd_program /usr/lib/squid/ssl_crtd -s /mnt/squid/squid_ssldb -M 10MB -b 2048
  21. sslcrtd_children 5
  22. sslproxy_capath /etc/ssl/certs/
  23. sslproxy_options NO_SSLv2,NO_SSLv3,SINGLE_DH_USE,SINGLE_ECDH_USE
  24. sslproxy_cipher EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:HIGH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS
  25. sslproxy_cert_error allow all
  26. sslproxy_flags DONT_VERIFY_PEER
  27. sslproxy_cert_adapt setValidAfter all
  28. sslproxy_cert_adapt setValidBefore all

  29. logfile_rotate 2
  30. debug_options rotate=2
  31. shutdown_lifetime 3 seconds
  32. # Allow local network(s) on interface(s)
  33. #设置连接网段
  34. acl localnet src  192.168.0.0/16
  35. forwarded_for delete
  36. #via off
  37. uri_whitespace strip
  38. #设置 dns 服务器
  39. dns_nameservers 192.168.1.233

  40. #设置内存缓存大小 1G
  41. cache_mem 1024 MB
  42. maximum_object_size_in_memory 4096 KB
  43. #memory_replacement_policy heap GDSF
  44. #cache_replacement_policy heap LFUDA
  45. minimum_object_size 0 KB
  46. maximum_object_size 16 MB
  47. #设置磁盘缓存大小 10G
  48. cache_dir aufs /mnt/squid/cache 10240 16 256
  49. offline_mode off
  50. cache_swap_low 90
  51. cache_swap_high 95
  52. cache allow all

  53. refresh_pattern -i (\.|-)(ico(.*)?|pn[pg]|(g|t)iff?|jpe?g(2|3|4)?|psd|c(d|b)r|cad|bmp|img)(\?.*)?$ 21600 100% 43200 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-no-store ignore-private ignore-auth
  54. refresh_pattern -i (\.|-)(webm|(x-)?swf|mp(eg)?(3|4)|mpe?g(av)?|(x-)?f(l|4)v|divx?|rmvb?|mov|trp|ts|avi|m38u|wmv|wmp|m4v|mkv|asf|dv|vob|3gp?2?)(\?.*)?$ 21600 100% 43200 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-no-store ignore-private ignore-auth

  55. refresh_pattern -i (\.|-)(xml|js|jsp|txt|css)(\?.*)?$ 360 40% 1440 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-no-store ignore-private ignore-auth
  56. refresh_pattern -i .index.(html|htm)$ 0 40% 1440

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

  62. #Remote proxies

  63. # Setup some default acls
  64. # ACLs all, manager, localhost, and to_localhost are predefined.
  65. acl allsrc src all
  66. acl safeports port 21 70 80 210 280 443 488 563 591 631 777 901  3128 3129 1025-65535
  67. acl sslports port 443 563  

  68. acl purge method PURGE
  69. acl connect method CONNECT

  70. # Define protocols used for redirects
  71. acl HTTP proto HTTP
  72. acl HTTPS proto HTTPS

  73. # SslBump Peek and Splice
  74. # <a href="http://wiki.squid-cache.org/Features/SslPeekAndSplice" target="_blank">http://wiki.squid-cache.org/Features/SslPeekAndSplice</a>
  75. # <a href="http://wiki.squid-cache.org/ConfigExamples/Intercept/SslBumpExplicit" target="_blank">http://wiki.squid-cache.org/Conf ... ept/SslBumpExplicit</a>
  76. # Match against the current step during ssl_bump evaluation [fast]
  77. # Never matches and should not be used outside the ssl_bump context.
  78. #
  79. # At each SslBump step, Squid evaluates ssl_bump directives to find
  80. # the next bumping action (e.g., peek or splice). Valid SslBump step
  81. # values and the corresponding ssl_bump evaluation moments are:
  82. #   SslBump1: After getting TCP-level and HTTP CONNECT info.
  83. #   SslBump2: After getting TLS Client Hello info.
  84. #   SslBump3: After getting TLS Server Hello info.
  85. # These ACLs exist even when 'SSL/MITM Mode' is set to 'Custom' so that
  86. # they can be used there for custom configuration.
  87. acl step1 at_step SslBump1
  88. acl step2 at_step SslBump2
  89. acl step3 at_step SslBump3
  90. http_access allow manager localhost

  91. http_access deny manager
  92. http_access allow purge localhost
  93. http_access deny purge
  94. http_access deny !safeports
  95. http_access deny CONNECT !sslports

  96. # Always allow localhost connections
  97. http_access allow localhost

  98. quick_abort_min -1 KB
  99. quick_abort_max 0 KB
  100. request_body_max_size 0 KB
  101. delay_pools 1
  102. delay_class 1 2
  103. delay_parameters 1 -1/-1 -1/-1
  104. delay_initial_bucket_level 100
  105. delay_access 1 allow allsrc

  106. # Reverse Proxy settings

  107. # Custom options before auth

  108. ssl_bump peek step1
  109. ssl_bump bump all
  110. # Setup allowed ACLs
  111. # Allow local network(s) on interface(s)
  112. http_access allow localnet
  113. # Default block all to be sure
  114. http_access deny allsrc

  115. #上面有中文注释的都要改一下。
复制代码
# 检查配置,没有报错就启动。
  1. squid -k parse
复制代码
  1. /etc/init.d/squid restart
复制代码
# 客户端设置代理后,以下命令查看经过 squid 的链接
  1. tail -f /var/squid/access.log
复制代码
# 以下命令查看命中缓存的连接
  1. tail -f /var/squid/access.log | grep HIT
复制代码

使用这个代理访问 https 网站有安全风险,好像是说所有 https 网站都不加密了?我也不懂,反正不要使用代理访问银行网站之类的。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-18 20:33

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表