我们一般使用的运营商的宽带默认使用的是公共DNS解析服务,但是公共DNS会存在不安全问题、广告问题、行为跟踪等问题。于是就有了自己搭建DNS的服务,AdGuard 就是一个支持自建DNS解析服务的程序,可以安装在Windows、Mac、Android、iOS、浏览器插件、甚至路由器和虚拟机里面,使用自己搭建的DNS服务,优点在于可以自己管理设备的网络访问行为,更加安全,屏蔽一些发烦人的广告。AdGuard 是拥有可获取最佳网络冲浪体验所需全部功能的独特程序。其组合了世界上最高级的广告拦截器,隐私保护模块以及家长控制 - 可协同任何浏览器和应用工作。过滤器是适用于广告内容(包括横幅、弹出广告等等)过滤规则的集合。AdGuard 设有由我们自主创建的基本过滤器。且 AdGuard 开发者不断改进并补充它们,希望能够满足大部分用户的需求。因此,每一个 AdGuard 应用程序随时都可以自主更新所开启的过滤器。
AdGuard Home官网
https://adguard.com/zh_cn/welcome.html
AdGuard Home官方下载:
https://github.com/AdguardTeam/AdGuardHome/releases
功能介绍
广告拦截
安全网络冲浪
隐私保护
家长控制
保护您的数据
在线掩饰自己
安装开始
CentOS 7 安装方法如下:(可根据自己的平台下载最新版本)
#下载AdGuard Home wget https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.108.0-b.41/AdGuardHome_linux_amd64.tar.gz #解压 tar -zxvf AdGuardHome_linux_amd64.tar.gz #进入AdGuardHome目录 cd AdGuardHome #放行3000端口(AdGuardHome初始化需要使用) #firewalld放行3000端口 firewall-cmd --zone=public --add-port=3000/tcp --permanent firewall-cmd --reload #iptables放行3000端口 iptables -A INPUT -p tcp --dport 3000 -j ACCEPT service iptables save #启动AdGuard Home ./AdGuardHome
额外设置
为了方便管理,可以继续输入命令把AdGuard安装为系统服务,这样设置以后你的AdGuard dns服务即使服务器重启以后开可以自动启动为你服务。
#设置为服务 ./AdGuardHome -s install #启动 systemctl start AdGuardHome #开机自启 systemctl enable AdGuardHome #重启 systemctl restart AdGuardHome #停止 systemctl stop AdGuardHome
DNS默认使用53(TCP/UDP)端口进行通信,因此别忘记放行53端口,否则DNS无法正常使用。如果安装了宝塔面板,可在面板内操作。
#firewalld放行53端口 firewall-cmd --zone=public --add-port=53/tcp --permanent firewall-cmd --zone=public --add-port=53/udp --permanent firewall-cmd --reload #iptables放行53端口 iptables -A INPUT -p tcp --dport 53 -j ACCEPT iptables -A INPUT -p udp --dport 53 -j ACCEPT service iptables save
浏览器打开http://IP:3000,就会打开安装界面。
端口设置
设置管理员账号和密码
一些在其他设备中使用DNS服务的简单教程
安装完成
设置guard Home
设置上游DNS:
#谷歌分流 [/*.bing.net/]tls://dns.google [/steamcommunity.com/]tls://dns.google [/*.steampowered.com/]tls://dns.google [/*.akamaihd.net/]tls://dns.google [/steam-chat.com/]tls://dns.google [/*.steamstatic.com/]tls://dns.google [/*.xboxlive.com/]tls://dns.google [/*.microsoft.com/]tls://dns.google [/*.epicgames.com/]tls://dns.google [/*.digitalchina.com/]tls://dns.google [/*.cloudfront.net/]tls://dns.google #cloudflare分流 [/*.bing.net/]https://dns.cloudflare.com/dns-query [/steamcommunity.com/]https://dns.cloudflare.com/dns-query [/*.steampowered.com/]https://dns.cloudflare.com/dns-query [/*.akamaihd.net/]https://dns.cloudflare.com/dns-query [/steam-chat.com/]https://dns.cloudflare.com/dns-query [/*.steamstatic.com/]https://dns.cloudflare.com/dns-query [/*.xboxlive.com/]https://dns.cloudflare.com/dns-query [/*.microsoft.com/]https://dns.cloudflare.com/dns-query [/*.epicgames.com/]https://dns.cloudflare.com/dns-query [/*.digitalchina.com/]https://dns.cloudflare.com/dns-query [/*.cloudfront.net/]https://dns.cloudflare.com/dns-query #DOH https://dns.alidns.com/dns-query https://dns.pub/dns-query https://dns.cloudflare.com/dns-query #DOT tls://dns.alidns.com tls://dns.pub tls://dns.google 并行请求增加请求速度 注:谷歌分流以及cloudflare针对的是一些国内DNS会污染的域名,可事先ping一下dns.google,如果服务器无法连接到dns.google或延迟过高可删除之。相应的在黑名单中添加上Steam加速规则。
或者添加这个
tls://dns.pub https://dns.pub/dns-query tls://dns.alidns.com https://dns.alidns.com/dns-query
Bootstrap DNS 服务器
180.76.76.76 219.141.136.10 119.29.29.29 119.28.28.28 223.5.5.5 223.6.6.6
DNS 服务配置
速度限制一般设置为0即可!
DNS缓存配置
缓存大小为1024*1024*4=4194304 4m足够了
覆盖最小TTL值可设置为300
覆盖最大TTL值可设置为3600
可不设置保持默认
开启乐观缓存增快访问速度!
黑名单
Oisd Big https://big.oisd.nl/ Oisd Nfsw https://nsfw.oisd.nl/ anti-AD https://anti-ad.net/easylist.txt ADgk https://cdn.jsdelivr.net/gh/banbendalao/ADgk@master/ADgk.txt No Google https://adguardteam.github.io/HostlistsRegistry/assets/filter_37.txt 10007 https://raw.gitmirror.com/lingeringsound/10007/main/adb.txt 1024 https://raw.githubusercontent.com/Goooler/1024_hosts/master/hosts yhosts https://raw.githubusercontent.com/VeleSila/yhosts/master/hosts Github加速1 https://file-git.trli.club/Domains/AccelerateHosts/github-hosts.txt Github加速2 https://raw.hellogithub.com/hosts 可按需添加 Steam加速:https://cdn.jsdelivr.net/gh/pboymt/Steam520/hosts 但由于上游服务器对Steam服务进行谷歌分流故不需要添加
或者添加这个
anti-AD https://anti-ad.net/easylist.txt
白名单
anti白名单:https://raw.githubusercontent.com/privacy-protection-tools/dead-horse/master/anti-ad-white-list.txt 可按需添加冷漠白名单:https://file-git.trli.club/allo
自定义规则
#知乎 ||api.zhihu.com/commercial_api/launch_v2^ ||api.zhihu.com/commercial_api/real_time_launch_v2^ ||api.zhihu.com/ad-style-service/request ||api.zhihu.com/fringe/ad ||api.zhihu.com/appview/api/v4/answers/*/recommendations*hb_answer_ad=0 ||api.zhihu.com/answers/*/comments/featured-comment-ad ||api.zhihu.com/moments*$replace=/\"adjson\"/\"adnull\"/s ||api.zhihu.com/topstory/recommend*$replace=/\"adjson\"/\"adnull\"/s ||api.zhihu.com/v4/questions/*/answers*$replace=/\"adjson\"/\"adnull\"/s ||api.zhihu.com/people/self$replace=/\"vip_info\"/\"null_vip\"/s @@||www.zhihu.com/api/v4/search_v3 ##大数据广告追踪 ||apd-pcdnwxstat.teg.tencent-cloud.net^ ||apd-pcdnwxnat.teg.tencent-cloud.net^ ||apd-pcdnvodstat.teg.tencent-cloud.net^ ||apd-vodp2plogin.teg.tencent-cloud.net^ ||gd.xinhuanet.com^$important ||ad7.com^$important ||nequal.com^$important ||n1q.cn^$important ||nequal.cn^$important ||chance-ad.com^$important ||zhihuiyun.net.cn^$important ||71360.com^$important ||reyun.com^$important ||onemob.mobi^$important ||emar.com^$important ||gozendata.com^$important ||gzads.com^$important ||gz-data.com^$important ||dwz.cn^ ||www.estrongs.com^ #欢太 @@||onewsvod.com^ #@@||client-uc.heytapmobi.com^ @@||pgdt.gtimg.cn^ @@||heytapmobi.com @@||store.heytapimage.com @@||heytapimage.com^ @@||huluxia.com^ @@||pan.quark.cn^ #拼多多 ||social.pinduoduo.com^$important ||4pn.cn^$important ||4a9.cn^$important ||3p4.cn^$important ||y4n.cn^$important ||u7x.cn^$important ||metrics.icloud.com^$important ||aqdlt.com^$important ||aqdz91.com^$important ||aqdz149.com^$important ||appmetrica.yandex.ru^$important ||share.jileme.net^$important #字节系 AD API SDK 屏蔽 /zijieapi.*/ /byteorge.*/ /bytegoofy.*/ /bytedance.*/ /snssdk.*/ /pangolin-sdk.*/ /lf.fqnovel.*/ /ad-sign.*/ /fqnovelvod.*/ /mgsdk-sign.*/ ||dig.bdurl.net^$important ||activity-ag.awemeughun.com^$important ||msync-im1-vip6-std.easemob.com^$important ||apd-pcdnwxlogin.teg.tencent-cloud.net^$important ||sf3-ttcdn-tos.pstatp.com^$important ||sf3-fe-tos.pglstatp-toutiao.com^$important ||skdisplay.jd.com^$important ||settings.ttwebview.com^$important #微信直连 @@||szaxshort.weixin.qq.com^$important @@||axshort.weixin.qq.com^$important @@||mldisas.weixin.qq.com^$important @@||szquic.weixin.qq.com^$important @@||long.weixin.qq.com^$important @@||mlshort.pay.weixin.qq.com^$important @@||minorlong.weixin.qq.com^$important @@||shshort.pay.weixin.qq.com^$important @@||short.pay.weixin.qq.com^$important @@||shminorlong.weixin.qq.com^$important @@||extshort.weixin.qq.com^$important @@||shextshort.weixin.qq.com^$important @@||short.weixin.qq.com^$important @@||szlong.weixin.qq.com^$important @@||szextshort.weixin.qq.com^$important @@||mlminorshort.weixin.qq.com^$important @@||mllong.weixin.qq.com^$important #@@||dns.weixin.qq.com.cn^$important @@||szminorlong.weixin.qq.com^$important @@||mlminorlong.weixin.qq.com^$important @@||szfindershort.weixin.qq.com^$important @@||shquic.weixin.qq.com^$important @@||quic.weixin.qq.com^$important @@||mlfindershort.weixin.qq.com^$important @@||minorshort.weixin.qq.com^$important @@||shdisas.weixin.qq.com^$important @@||mlquic.weixin.qq.com^$important @@||szshort.pay.weixin.qq.com^$important @@||szshort.weixin.qq.com^$important @@||mlextshort.weixin.qq.com^$important @@||mlaxshort.weixin.qq.com^$important @@||findershort.weixin.qq.com^$important @@||szdisas.weixin.qq.com^$important @@||mlshort.weixin.qq.com^$important @@||szminorshort.weixin.qq.com^$important @@||hklong.weixin.qq.com^$important @@||hkdisas.weixin.qq.com^$important @@||hkshort6.weixin.qq.com^$important @@||sglong.wechat.com^$important @@||sgshort.wechat.com^$important @@||sgminorshort.wechat.com^$important @@||hkminorshort.weixin.qq.com^$important @@||sgaxshort.wechat.com^$important @@||hkfindershort.weixin.qq.com^$important @@||hkaxshort.weixin.qq.com^$important @@||hkextshort.weixin.qq.com^$important @@||sgshort.pay.wechat.com^$important @@||sgfindershort.wechat.com^$important @@||hkshort.weixin.qq.com^$important @@||hkshort.pay.weixin.qq.com^$important @@||hkquic.weixin.qq.com^$important @@||res.servicewechat.com^$important @@||wximg.qq.com^$important @@||wxsnsdyvip.wxs.qq.com^$important @@||support.weixin.qq.com^$important @@||weixinc2c.tc.qq.com^$important @@||shp.qlogo.cn^$important @@||weixin110.qq.com^$important @@||mlsupport.weixin.qq.com^$important @@||mp.weixin.qq.com^$important @@||open.weixin.qq.com^$important @@||wxsnsdy.wxs.qq.com^$important @@||hksupport.weixin.qq.com^$important @@||wxsnsdythumb.wxs.qq.com^$important @@||mmsns.qpic.cn^$important @@||api.weixin.qq.com^$important @@||szsupport.weixin.qq.com^$important @@||shmmsns.qpic.cn^$important @@||szmmsns.qpic.cn^$important @@||vweixinf.tc.qq.com^$important @@||c6.y.qq.com^$important @@||weixin.qq.com^$important @@||wx.qlogo.cn^$important @@||wxapp.tc.qq.com^$important @@||emoji.qpic.cn^$important @@||resstatic.servicewechat.com^$important #番茄小说 ||polaris3-normal-lq.zijieapi.com^$app=com.dragon.read ||v3-novelapp.fqnovelvod.com^$app=com.dragon.read ||ads3-normal-lq.zijieapi.com^$app=com.dragon.read ||v3-novelapp.fqnovelvod.com^$app=com.dragon.read ||tnc3-aliec2.zijieapi.com^$app=com.dragon.read ||p9-developer-sign.bytemaimg.com^$app=com.dragon.read ||p3-novelfm-sign.novelfmpic.com^$app=com.dragon.read ||p9-novelfm-sign.novelfmpic.com^$app=com.dragon.read ||p3-novel.byteimg.com^$app=com.dragon.read ||gecko5-lq.zijieapi.com^$app=com.dragon.read ||p6-ad-sign.byteimg.com^$app=com.dragon.read ||frontier-toutiao.snssdk.com^$app=com.dragon.read ||p3-webcast-sign.douyinpic.com^$app=com.dragon.read ||p9-ad-sign.byteimg.com^$app=com.dragon.read ||ads5-normal-lq.zijieapi.com^$app=com.dragon.read ||v6-novelapp.fqnovelvod.com^$app=com.dragon.read ||abtest3-misc-lq.zijieapi.com^$app=com.dragon.read ||sf3-fe-tos.pglstatp-toutiao.com^$app=com.dragon.read ||vcs.zijieapi.com^$app=com.dragon.read ||imapi2.snssdk.com^$app=com.dragon.read ||tnc3-bjlgy.zijieapi.com^$app=com.dragon.read ||mon11-misc-lq.fqnovel.com^$app=com.dragon.read ||dig.bdurl.net^$app=com.dragon.read ||ma3-normal-lq.zijieapi.com^$app=com.dragon.read ||ma5-normal-lq.zijieapi.com^$app=com.dragon.read ||v9-be-pack.pglstatp-toutiao.com^$app=com.dragon.read ||beacon-api.aliyuncs.com^$app=com.dragon.read ||p26-be-pack-sign.pglstatp-toutiao.com^$app=com.dragon.read ||p3-be-pack-sign.pglstatp-toutiao.com^$app=com.dragon.read ||v6-be-pack.pglstatp-toutiao.com^$app=com.dragon.read ||tnc11-bjlgy.zijieapi.com^$app=com.dragon.read ||adash.man.aliyuncs.com^$app=com.dragon.read ||v3-be-pack.pglstatp-toutiao.com^$app=com.dragon.read ||tnc3-alisc1.zijieapi.com^$app=com.dragon.read ||p6-be-pack-sign.pglstatp-toutiao.com^$app=com.dragon.read ||is-lq.snssdk.com^$app=com.dragon.read ||p3-webcast.douyinpic.com^$app=com.dragon.read ||feedback-c.zijieapi.com^$app=com.dragon.read ||lf-cdn-tos.bytescm.com^$app=com.dragon.read ||api-access.pangolin-sdk-toutiao.com^$app=com.dragon.read ||skdisplay.jd.com^$app=com.dragon.read ||p26.douyinpic.com^$app=com.dragon.read ||log-api.pangolin-sdk-toutiao-b.com^$app=com.dragon.read ||p9-be-pack-sign.pglstatp-toutiao.com^$app=com.dragon.read ||pangolin-sdk-toutiao.com^ ||zijieapi.com^$app=com.dragon.read ||frontier-toutiao.snssdk.com^$app=com.dragon.read ||pangolin-sdk-toutiao-b.com^ ||ads5-normal-lf.zijieapi.com^$app=com.dragon.read ||pglstatp-toutiao.com^ ||p3-sign.douyinpic.com^ ||bsync3-normal-lq.zijieapi.com^ ||lf9-cdn-tos.bytegecko.com^$app=com.dragon.read ||gecko5-lq.zijieapi.com^ ||ec3-core-lq.ecombdapi.com^ ||log5-applog.fqnovel.com^ ||lf3-cdn-tos.bytegecko.com^ ||lf9-common-release.bytetos.com^ ||101-206-252-241.volcsiriusbd.com^ ||dig.zjurl.cn^ ||gecko.snssdk.com^ ||feedback-c.zijieapi.com^ ||ec5-core-lq.ecombdapi.com^ ||saveu5-normal-lq.zijieapi.com^$app=com.dragon.read ||ads3-normal-lq.zijieapi.com^ ||203.119.216.50:443^$app=com.dragon.read ||101.206.201.225:443^$app=com.dragon.read ||113.207.83.53:443^$app=com.dragon.read ||101.206.201.225:443^$app=com.dragon.read ||lf26-common-release.bytetos.com^ ||113.207.83.53:443^$app=com.dragon.read ||116.169.11.31:443^$app=com.dragon.read ||113.207.83.53:443^$app=com.dragon.read ||116.169.11.27:443^$app=com.dragon.read ||116.169.11.31:443^$app=com.dragon.read ||p6-be-pack-sign.pglstatp-toutiao.com^ ||112.192.22.90:443^ ||101.207.252.229:443^ ||tnc3-alisc1.zijieapi.com^ ||sf3-pitaya-tos.pstatp.com^ ||lf6-common-release.bytetos.com^ ||reading.snssdk.com^ ||api.toutiaoapi.com^ ||webcast5-open-lq.douyin.com^ ||lf3-webcastcdn-tos-sign.douyinstatic.com^ ||opencloud.wostore.cn^ ||p9-reading-sign.fqnovelpic.com^$app=com.dragon.read ||lf-cdn-tos.bytescm.com^ ||p6-developer-sign.bytemaimg.com^ ||sf1-pitaya-tos.pstatp.com^ ||112.192.22.90:443^ ||beacon-api.aliyuncs.com^ ||p3-be-pack-sign.pglstatp-toutiao.com^ ||101.207.252.229:443^ ||tnc3-bjlgy.zijieapi.com^ ||lf3-short.bytetos.com^ ||116.132.223.77:443^ ||123.6.82.180:80^ ||v3-be-pack.pglstatp-toutiao.com^ ||p9-reading.byteimg.com^ ||p6-novelfm-sign.novelfmpic.com^ ||p3-developer-sign.bytemaimg.com^ ||p9-developer-sign.bytemaimg.com^ ||112-194-48-224-yf016101.free-lbv6.idouyinvod.com^ ||msg.umengcloud.com^ ||112.192.22.90:443^ ||v6-be-pack.pglstatp-toutiao.com^ ||sf3-fe-tos.pglstatp-toutiao.com^ ||pull-flv-f13.douyincdn.com^ ||112.194.65.102:80^ ||wxsnsdythumb.wxs.qq.com^ ||wxsnsdy.wxs.qq.com^ ||mp.weixin.qq.com^ ||p6-ad-sign.byteimg.com^ ||p9-ad-sign.byteimg.com^ ||v6-novelapp.fqnovelvod.com^ ||v3-novelapp.fqnovelvod.com^ ||116.169.48.137:443^ ||111.13.24.68:443^ ||p9-be-pack-sign.pglstatp-toutiao.com^ ||adash.man.aliyuncs.com^ ||p26-be-pack-sign.pglstatp-toutiao.com^ ||p26-tt.byteimg.com^ ||p1-tt.byteimg.com^ ||rtlog5-applog-lq.fqnovel.com^ ||v9-be-pack.pglstatp-toutiao.com^ ||imapi2.snssdk.com^ ||ads5-normal-lq.zijieapi.com^ ||log5-applog-lq.fqnovel.com^ ||polaris3-normal-lq.zijieapi.com^ ||skdisplay.jd.com^ ||log-api.pangolin-sdk-toutiao-b.com^ #微信公众号 @@||aeventlog.beacon.qq.com^ @@||cfg.flurry.com^ @@||data.flurry.com^ #@@||otheve.beacon.qq.com^ @@||tpstelemetry.tencent.com^ #酷安 ||ctobsnssdk.com^ ||pangolin.snssdk.com^ ||pangolin-sdk-toutiao.com^ ||pangolin-sdk-toutiao-b.com^ ||pglstatp-toutiao.com^ ||dm.toutiao.com^ ||ulogs.umeng.com^ ||aaid.umeng.com^ ||tnc*.zijieapi.com^ ||mssdk-bu.bytedance.com^ ! 帖子详情好物推荐 ||api2.coolapk.com/v6/feed/detail$replace=/"include_goods_ids":\[.*?]\,"include_goods":\[.*?]\,/ / ! 帖子详情赞助内容 ||api2.coolapk.com/v6/feed/detail$replace=/\,"detailSponsorCard":{.*}/}}/ ! 发现页去除酷品 ||api2.coolapk.com/v6/main/init$replace=/{"id":1170.*?}\,/ / ! 应用游戏页去除推广视频 ||api2.coolapk.com/v6/page/dataList$replace=/{"entityType":"card"\,"entityTemplate":"apkImageCard".*?\\u0022}"}\,/ / ! 去除首页还有什么值得买推广 ||api2.coolapk.com/v6/main/indexV8$replace=/{"entityType":"card"\,"entityTemplate":"listCard".*?}"}\,/ / ||ctobsnssdk.com^ ||pangolin.snssdk.com^ ||pangolin-sdk-toutiao.com^ ||pangolin-sdk-toutiao-b.com^ #番茄 ||pangolin-sdk-toutiao.com^ ||zijieapi.com^$app=com.dragon.read ||frontier-toutiao.snssdk.com^$app=com.dragon.read ||pangolin-sdk-toutiao-b.com^ ||ads5-normal-lf.zijieapi.com^$app=com.dragon.read ||pglstatp-toutiao.com^ #18bit ||file.7youxi.com^ ||cdn.51img3.com^ ||test.18bit.cn^
加密设置
进行了加密设置才能使用DOH和DOT
服务器名称填写为你的域名:主域名 或者 子域名
同时申请域名证书,将证书填入下面证书出。
HTTPS端口填入4443之后使用宝塔进行反代理 DOT端口填写常规的853就行
DOQ不知道干啥的默认就行。
填写完证书和密钥后如果显示:
警告: validating certificate pair: certificates has no IP addresses; DNS-over-TLS won't be advertised via DDR
实属正常
这样Adguard Home的设置就完成了。
安装宝塔面板
(1)基础安装与设置:
宝塔安装命令自行去官方查看吧!
进入宝塔面板后台。
使用宝塔面板自动配置LNMP服务器环境。
在宝塔面板的安全–防火墙中放行Adguardhome需要使用的端口。例如:443 4443 3000 10000 853等等
(2)使用nginx进行反代理,使得DOH运行在443端口上
在宝塔面板后台添加站点,输入DNS服务器的域名。
PHP版本设置为纯静态。
在SSL证书中填写域名证书(与Adguard Home中证书相同)
进入站点设置中的配置文件,删除ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
后面所有内容并添加
ssl_prefer_server_ciphers on; ssl_early_data on; ssl_ecdh_curve X25519:P-256:P-384; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; error_page 500 https://$host$request_uri; location / { proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:1080; # 此处为程序运行时指定的端口,即adgh中的访问端口 } location ~ .*.(gif|jpg|jpeg|png|bmp|swf|css|js)$ { proxy_pass http://127.0.0.1:1080; # 此处为程序运行时指定的端口,即adgh中的访问端口 proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } location /dns-query { proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_buffering off; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass https://dns.laison.ltd:4443/dns-query; # 地址为adhg中监听的DOH服务地址 } }
例如我们使用上面所讲的主域名进行配置,将4443端口内容转发到443端口,配置如下:
server { listen 80; listen 443 ssl http2; server_name 域名; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/域名; #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 #error_page 404/404.html; #HTTP_TO_HTTPS_START if ($server_port !~ 443){ rewrite ^(/.*)$ https://$host$1 permanent; } #HTTP_TO_HTTPS_END ssl_certificate /www/server/panel/vhost/cert/域名/fullchain.pem; ssl_certificate_key /www/server/panel/vhost/cert/域名/privkey.pem; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_early_data on; ssl_ecdh_curve X25519:P-256:P-384; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; error_page 500 https://$host$request_uri; location / { proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:3000; # 此处为程序运行时指定的端口,即adgh中的访问端口 } location ~ .*.(gif|jpg|jpeg|png|bmp|swf|css|js)$ { proxy_pass http://127.0.0.1:3000; # 此处为程序运行时指定的端口,即adgh中的访问端口 proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } location /dns-query { proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_buffering off; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass https://域名:4443/dns-query; # 地址为adhg中监听的DOH服务地址 } }
保存设置,并重启nginx。
通过nginx反向代理,将adguardhome原本不运行在443端口上的DOH服务反向代理到443端口上。
优点就是如果你想在服务器上搭建其他网页例子博客就不会对443端口进行干扰。
完成
本文作者为萝莉工坊,转载请注明。