[{"data":1,"prerenderedAt":689,"buildId":690},["ShallowReactive",2],{"-docs-deployment-docker-description":3,"docs--docs-deployment-docker":16,"docs-navigation-zh-CN":597,"surround--docs-deployment-docker":686},{"data":4,"body":5},{},{"type":6,"children":7},"root",[8],{"type":9,"tag":10,"props":11,"children":12},"element","p",{},[13],{"type":14,"value":15},"text","用 Docker Compose 部署 Nginx，配置同网络容器或宿主机反向代理，并排查常见网络问题。",{"id":17,"title":18,"body":19,"category":578,"description":15,"difficulty":579,"extension":580,"index":581,"keywords":579,"links":582,"meta":590,"navigation":579,"path":592,"requires":579,"seo":593,"sitemap":594,"stem":595,"__hash__":596},"docs\u002Fdocs\u002F2.deployment\u002F1.docker.md","Docker Nginx 反向代理",{"type":20,"value":21,"toc":569},"minimark",[22,27,39,246,249,253,264,357,360,370,426,429,432,476,480,483,533,556,565],[23,24,26],"h2",{"id":25},"compose-基础结构","Compose 基础结构",[10,28,29,30,34,35,38],{},"使用自定义桥接网络 ",[31,32,33],"code",{},"webnet"," 让同栈容器互通，同时通过 ",[31,36,37],{},"extra_hosts"," 允许容器访问宿主机服务：",[40,41,47],"pre",{"className":42,"code":43,"filename":44,"language":45,"meta":46,"style":46},"language-yaml shiki shiki-themes github-light github-light github-dark","services:\n  nginx:\n    image: nginx:latest\n    container_name: nginx\n    restart: always\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n    volumes:\n      - .\u002Fconf\u002Fnginx.conf:\u002Fetc\u002Fnginx\u002Fnginx.conf:ro\n      - .\u002Fconf\u002Fconf.d:\u002Fetc\u002Fnginx\u002Fconf.d:ro\n      - .\u002Fssl:\u002Fetc\u002Fnginx\u002Fssl:ro\n      - .\u002Flogs:\u002Fvar\u002Flog\u002Fnginx\n    extra_hosts:\n      - \"host.docker.internal:host-gateway\"\n    networks:\n      - webnet\n\nnetworks:\n  webnet:\n    name: webnet\n    driver: bridge\n","~\u002Fnginx\u002Fdocker-compose.yml","yaml","",[31,48,49,62,70,83,94,105,113,122,130,138,146,154,162,170,178,186,194,202,209,217,225,235],{"__ignoreMap":46},[50,51,54,58],"span",{"class":52,"line":53},"line",1,[50,55,57],{"class":56},"sovSZ","services",[50,59,61],{"class":60},"sxrX7",":\n",[50,63,65,68],{"class":52,"line":64},2,[50,66,67],{"class":56},"  nginx",[50,69,61],{"class":60},[50,71,73,76,79],{"class":52,"line":72},3,[50,74,75],{"class":56},"    image",[50,77,78],{"class":60},": ",[50,80,82],{"class":81},"sIIMD","nginx:latest\n",[50,84,86,89,91],{"class":52,"line":85},4,[50,87,88],{"class":56},"    container_name",[50,90,78],{"class":60},[50,92,93],{"class":81},"nginx\n",[50,95,97,100,102],{"class":52,"line":96},5,[50,98,99],{"class":56},"    restart",[50,101,78],{"class":60},[50,103,104],{"class":81},"always\n",[50,106,108,111],{"class":52,"line":107},6,[50,109,110],{"class":56},"    ports",[50,112,61],{"class":60},[50,114,116,119],{"class":52,"line":115},7,[50,117,118],{"class":60},"      - ",[50,120,121],{"class":81},"\"80:80\"\n",[50,123,125,127],{"class":52,"line":124},8,[50,126,118],{"class":60},[50,128,129],{"class":81},"\"443:443\"\n",[50,131,133,136],{"class":52,"line":132},9,[50,134,135],{"class":56},"    volumes",[50,137,61],{"class":60},[50,139,141,143],{"class":52,"line":140},10,[50,142,118],{"class":60},[50,144,145],{"class":81},".\u002Fconf\u002Fnginx.conf:\u002Fetc\u002Fnginx\u002Fnginx.conf:ro\n",[50,147,149,151],{"class":52,"line":148},11,[50,150,118],{"class":60},[50,152,153],{"class":81},".\u002Fconf\u002Fconf.d:\u002Fetc\u002Fnginx\u002Fconf.d:ro\n",[50,155,157,159],{"class":52,"line":156},12,[50,158,118],{"class":60},[50,160,161],{"class":81},".\u002Fssl:\u002Fetc\u002Fnginx\u002Fssl:ro\n",[50,163,165,167],{"class":52,"line":164},13,[50,166,118],{"class":60},[50,168,169],{"class":81},".\u002Flogs:\u002Fvar\u002Flog\u002Fnginx\n",[50,171,173,176],{"class":52,"line":172},14,[50,174,175],{"class":56},"    extra_hosts",[50,177,61],{"class":60},[50,179,181,183],{"class":52,"line":180},15,[50,182,118],{"class":60},[50,184,185],{"class":81},"\"host.docker.internal:host-gateway\"\n",[50,187,189,192],{"class":52,"line":188},16,[50,190,191],{"class":56},"    networks",[50,193,61],{"class":60},[50,195,197,199],{"class":52,"line":196},17,[50,198,118],{"class":60},[50,200,201],{"class":81},"webnet\n",[50,203,205],{"class":52,"line":204},18,[50,206,208],{"emptyLinePlaceholder":207},true,"\n",[50,210,212,215],{"class":52,"line":211},19,[50,213,214],{"class":56},"networks",[50,216,61],{"class":60},[50,218,220,223],{"class":52,"line":219},20,[50,221,222],{"class":56},"  webnet",[50,224,61],{"class":60},[50,226,228,231,233],{"class":52,"line":227},21,[50,229,230],{"class":56},"    name",[50,232,78],{"class":60},[50,234,201],{"class":81},[50,236,238,241,243],{"class":52,"line":237},22,[50,239,240],{"class":56},"    driver",[50,242,78],{"class":60},[50,244,245],{"class":81},"bridge\n",[23,247,248],{"id":248},"两种反向代理写法",[250,251,252],"h3",{"id":252},"反代同网络应用容器",[10,254,255,256,259,260,263],{},"容器重建后内网 IP 会变化，直接写 ",[31,257,258],{},"proxy_pass http:\u002F\u002Fapp:3000;"," 会导致 Nginx 启动时解析失败或缓存旧 IP。使用 Docker 内置 DNS ",[31,261,262],{},"127.0.0.11"," 配合变量形式的上游地址，让 Nginx 在请求时动态解析：",[40,265,270],{"className":266,"code":267,"filename":268,"language":269,"meta":46,"style":46},"language-nginx shiki shiki-themes github-light github-light github-dark","location \u002F {\n    resolver 127.0.0.11 valid=30s;\n    set $upstream app:3000;\n    proxy_pass http:\u002F\u002F$upstream;\n    proxy_http_version 1.1;\n    proxy_set_header Host $host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n}\n","conf\u002Fconf.d\u002Fapp.conf","nginx",[31,271,272,285,296,304,312,323,331,338,345,352],{"__ignoreMap":46},[50,273,274,278,282],{"class":52,"line":53},[50,275,277],{"class":276},"s8jYJ","location",[50,279,281],{"class":280},"snPdu"," \u002F ",[50,283,284],{"class":60},"{\n",[50,286,287,290,293],{"class":52,"line":64},[50,288,289],{"class":276},"    resolver ",[50,291,262],{"class":292},"sBjJW",[50,294,295],{"class":60}," valid=30s;\n",[50,297,298,301],{"class":52,"line":72},[50,299,300],{"class":276},"    set ",[50,302,303],{"class":60},"$upstream app:3000;\n",[50,305,306,309],{"class":52,"line":85},[50,307,308],{"class":276},"    proxy_pass ",[50,310,311],{"class":60},"http:\u002F\u002F$upstream;\n",[50,313,314,317,320],{"class":52,"line":96},[50,315,316],{"class":276},"    proxy_http_version ",[50,318,319],{"class":292},"1.1",[50,321,322],{"class":60},";\n",[50,324,325,328],{"class":52,"line":107},[50,326,327],{"class":276},"    proxy_set_header ",[50,329,330],{"class":60},"Host $host;\n",[50,332,333,335],{"class":52,"line":115},[50,334,327],{"class":276},[50,336,337],{"class":60},"X-Real-IP $remote_addr;\n",[50,339,340,342],{"class":52,"line":124},[50,341,327],{"class":276},[50,343,344],{"class":60},"X-Forwarded-For $proxy_add_x_forwarded_for;\n",[50,346,347,349],{"class":52,"line":132},[50,348,327],{"class":276},[50,350,351],{"class":60},"X-Forwarded-Proto $scheme;\n",[50,353,354],{"class":52,"line":140},[50,355,356],{"class":60},"}\n",[250,358,359],{"id":359},"反代宿主机进程",[10,361,362,363,365,366,369],{},"若应用通过 PM2 等方式直接跑在宿主机端口，Compose 需配置上面的 ",[31,364,37],{},"，随后直接指向 ",[31,367,368],{},"host.docker.internal","：",[40,371,373],{"className":266,"code":372,"filename":268,"language":269,"meta":46,"style":46},"location \u002F {\n    proxy_pass http:\u002F\u002Fhost.docker.internal:3000;\n    proxy_http_version 1.1;\n    proxy_set_header Host $host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n}\n",[31,374,375,383,390,398,404,410,416,422],{"__ignoreMap":46},[50,376,377,379,381],{"class":52,"line":53},[50,378,277],{"class":276},[50,380,281],{"class":280},[50,382,284],{"class":60},[50,384,385,387],{"class":52,"line":64},[50,386,308],{"class":276},[50,388,389],{"class":60},"http:\u002F\u002Fhost.docker.internal:3000;\n",[50,391,392,394,396],{"class":52,"line":72},[50,393,316],{"class":276},[50,395,319],{"class":292},[50,397,322],{"class":60},[50,399,400,402],{"class":52,"line":85},[50,401,327],{"class":276},[50,403,330],{"class":60},[50,405,406,408],{"class":52,"line":96},[50,407,327],{"class":276},[50,409,337],{"class":60},[50,411,412,414],{"class":52,"line":107},[50,413,327],{"class":276},[50,415,344],{"class":60},[50,417,418,420],{"class":52,"line":115},[50,419,327],{"class":276},[50,421,351],{"class":60},[50,423,424],{"class":52,"line":124},[50,425,356],{"class":60},[23,427,428],{"id":428},"常用校验与重载",[10,430,431],{},"修改配置后先检查语法再平滑重载，避免直接重启导致报错下线：",[40,433,437],{"className":434,"code":435,"filename":436,"language":436,"meta":46,"style":46},"language-sh shiki shiki-themes github-light github-light github-dark","docker compose exec nginx nginx -t\ndocker compose exec nginx nginx -s reload\n","sh",[31,438,439,458],{"__ignoreMap":46},[50,440,441,444,447,450,453,455],{"class":52,"line":53},[50,442,443],{"class":280},"docker",[50,445,446],{"class":81}," compose",[50,448,449],{"class":81}," exec",[50,451,452],{"class":81}," nginx",[50,454,452],{"class":81},[50,456,457],{"class":292}," -t\n",[50,459,460,462,464,466,468,470,473],{"class":52,"line":64},[50,461,443],{"class":280},[50,463,446],{"class":81},[50,465,449],{"class":81},[50,467,452],{"class":81},[50,469,452],{"class":81},[50,471,472],{"class":292}," -s",[50,474,475],{"class":81}," reload\n",[23,477,479],{"id":478},"网络排查ipv4-不通但-ipv6-正常","网络排查：IPv4 不通但 IPv6 正常",[10,481,482],{},"Docker 对 IPv4 依赖 iptables DNAT 做端口映射，容易与云厂商安全组或宿主机防火墙规则冲突：",[40,484,486],{"className":434,"code":485,"filename":436,"language":436,"meta":46,"style":46},"# 检查端口映射与 NAT 规则\ndocker port nginx\nsudo iptables -t nat -L -n | grep 443\n",[31,487,488,494,504],{"__ignoreMap":46},[50,489,490],{"class":52,"line":53},[50,491,493],{"class":492},"sCsY4","# 检查端口映射与 NAT 规则\n",[50,495,496,498,501],{"class":52,"line":64},[50,497,443],{"class":280},[50,499,500],{"class":81}," port",[50,502,503],{"class":81}," nginx\n",[50,505,506,509,512,515,518,521,524,527,530],{"class":52,"line":72},[50,507,508],{"class":280},"sudo",[50,510,511],{"class":81}," iptables",[50,513,514],{"class":292}," -t",[50,516,517],{"class":81}," nat",[50,519,520],{"class":292}," -L",[50,522,523],{"class":292}," -n",[50,525,526],{"class":276}," |",[50,528,529],{"class":280}," grep",[50,531,532],{"class":292}," 443\n",[10,534,535,536,539,540,543,544,547,548,551,552,555],{},"处理顺序：优先核对云厂商安全组与 ",[31,537,538],{},"ufw"," 是否放行 ",[31,541,542],{},"80","\u002F",[31,545,546],{},"443","；若环境支持 IPv6，建议同时配置 ",[31,549,550],{},"AAAA"," 解析；尽量避免使用 ",[31,553,554],{},"network_mode: host"," 绕过隔离。",[10,557,558,559,564],{},"HTTPS 证书选型与 Nginx SSL 配置见 ",[560,561,563],"a",{"href":562},"\u002Fdocs\u002Fdeployment\u002Fssl-certificate","SSL 证书配置","。",[566,567,568],"style",{},"html pre.shiki code .sovSZ, html code.shiki .sovSZ{--shiki-light:#22863A;--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":46,"searchDepth":64,"depth":72,"links":570},[571,572,576,577],{"id":25,"depth":64,"text":26},{"id":248,"depth":64,"text":248,"children":573},[574,575],{"id":252,"depth":72,"text":252},{"id":359,"depth":72,"text":359},{"id":428,"depth":64,"text":428},{"id":478,"depth":64,"text":479},"infra",null,"md",false,[583,587],{"label":584,"icon":585,"to":586},"Docker Engine 安装文档","i-lucide-book-open","https:\u002F\u002Fdocs.docker.com\u002Fengine\u002Finstall\u002F",{"label":588,"icon":585,"to":589},"Nginx resolver 文档","https:\u002F\u002Fnginx.org\u002Fen\u002Fdocs\u002Fhttp\u002Fngx_http_core_module.html#resolver",{"date":591},"2026-11-30T17:42:46+08:00","\u002Fdocs\u002Fdeployment\u002Fdocker",{"title":18,"description":15},{"loc":592},"docs\u002F2.deployment\u002F1.docker","i7I5Tbqck0AlF1WY5WmrCRE1_haLoCfpb7D9M4QUEoQ",[598],{"title":599,"path":600,"stem":601,"children":602,"page":581},"Docs","\u002Fdocs","docs",[603,625,657,674],{"title":604,"category":579,"description":605,"icon":606,"date":591,"path":607,"stem":608,"children":609,"page":581},"Nuxt 工程","Nuxt UI 样式、身份认证与 SSR 部署的排查记录","i-simple-icons-nuxt","\u002Fdocs\u002Fnuxt","docs\u002F1.nuxt",[610,615,620],{"title":611,"path":612,"stem":613,"category":579,"description":614},"Nuxt UI componentDetection 漏检","\u002Fdocs\u002Fnuxt\u002Fnuxt-ui-component-detection","docs\u002F1.nuxt\u002F1.nuxt-ui-component-detection","解决 @nuxt\u002Fui 开启 componentDetection 后，部分组件主题 CSS 未生成、样式完全缺失的问题。",{"title":616,"path":617,"stem":618,"category":579,"description":619},"自建服务器 GitHub OAuth 回调 500 排查","\u002Fdocs\u002Fnuxt\u002Fself-hosted-oauth-500","docs\u002F1.nuxt\u002F2.self-hosted-oauth-500","汇总自建 Docker + nginx 环境下 \u002Fauth\u002Fgithub 回调返回 500 的三种独立根因——出海代理超时、数据库连接串在构建期被固化、跨 Docker 网络 DNS 解析失败，提供速查表快速定位与逐一修复步骤。",{"title":621,"path":622,"stem":623,"category":579,"description":624},"Nuxt SSR + PM2 部署","\u002Fdocs\u002Fnuxt\u002Fssr-pm2-deploy","docs\u002F1.nuxt\u002F3.ssr-pm2-deploy","在宿主机用 PM2 集群运行 Nuxt SSR，并通过 Docker Nginx 反向代理与 Cloudflare 避坑要点。",{"title":626,"category":579,"description":627,"icon":628,"date":591,"path":629,"stem":630,"children":631,"page":581},"部署与运维","容器、数据库、证书与自动化发布","i-lucide-server","\u002Fdocs\u002Fdeployment","docs\u002F2.deployment",[632,633,638,641,647,652],{"title":18,"path":592,"stem":595,"category":578,"description":15},{"title":634,"path":635,"stem":636,"category":578,"description":637},"数据库部署","\u002Fdocs\u002Fdeployment\u002Fdatabase","docs\u002F2.deployment\u002F2.database","使用 Docker Compose 本地监听部署 PostgreSQL 与 Redis，配置备份恢复、PostGIS 及 Redis 持久化。",{"title":563,"path":562,"stem":639,"category":578,"description":640},"docs\u002F2.deployment\u002F3.ssl-certificate","Cloudflare Origin 证书与 Let's Encrypt（acme.sh）选型配置、Nginx HTTPS 片段与常见 TLS 故障排查。",{"title":642,"path":643,"stem":644,"category":645,"description":646},"GitHub Actions 发布容器镜像","\u002Fdocs\u002Fdeployment\u002Fgithub-actions","docs\u002F2.deployment\u002F4.github-actions","ci","用 GitHub Actions 发布镜像到 GHCR，解释镜像版本与容器重建后的反代行为。",{"title":648,"path":649,"stem":650,"category":645,"description":651},"GitHub CI 镜像加速","\u002Fdocs\u002Fdeployment\u002Fgithub-ci-mirror-acceleration","docs\u002F2.deployment\u002F5.github-ci-mirror-acceleration","在国内云服务器上通过同步腾讯云 TCR 或配置 Mihomo 代理，加速拉取 GitHub Actions 构建的容器镜像。",{"title":653,"path":654,"stem":655,"category":645,"description":656},"GitLab CI\u002FCD 排查","\u002Fdocs\u002Fdeployment\u002Fgitlab-ci","docs\u002F2.deployment\u002F6.gitlab-ci","记录 GitLab CI 配置加载、构建产物和部署通知之间的依赖关系。",{"title":658,"category":579,"description":659,"icon":660,"date":591,"path":661,"stem":662,"children":663,"page":581},"平台集成","地图服务与政务应用接入中的实际问题","i-lucide-plug","\u002Fdocs\u002Fplatforms","docs\u002F3.platforms",[664,669],{"title":665,"path":666,"stem":667,"category":579,"description":668},"iServer 踩坑归集","\u002Fdocs\u002Fplatforms\u002Fiserver","docs\u002F3.platforms\u002F1.iserver","记录使用超图 iServer 地图与数据服务过程中的接口选型、常见问题排查与实用查询技巧。",{"title":670,"path":671,"stem":672,"category":579,"description":673},"浙政钉 H5 应用埋点","\u002Fdocs\u002Fplatforms\u002Fdingtalk","docs\u002F3.platforms\u002F2.dingtalk","在浙政钉 H5 单页应用中配置 aplus_queue 手动采集，按路由发送 PV 并安全绑定异步用户信息。",{"title":675,"category":579,"description":676,"icon":677,"date":591,"path":678,"stem":679,"children":680,"page":581},"开发环境与工具","pnpm 供应链策略与版本自举等工具链排错记录","i-lucide-wrench","\u002Fdocs\u002Ftools","docs\u002F4.tools",[681],{"title":682,"path":683,"stem":684,"category":579,"description":685},"pnpm 常见故障排查","\u002Fdocs\u002Ftools\u002Fpnpm","docs\u002F4.tools\u002F1.pnpm","通过错误信息区分依赖信任降级阻断（ERR_PNPM_TRUST_DOWNGRADE）与 pnpm 自举崩溃。",[687,688],{"title":621,"path":622,"stem":623,"description":624,"children":-1},{"title":634,"path":635,"stem":636,"description":637,"children":-1},1796031846625,"fbd03a9e-6514-4b03-ba93-9f40ff4dbee5"]