NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
PerFectTime
V2EX  ›  NGINX

求教如何在反代中指定某目录不走反代,其他的目录走反代

  •  
  •   PerFectTime · Aug 24, 2020 · 1442 views
    This topic created in 2100 days ago, the information mentioned may be changed or developed.

    需求: 使用 nginx 反代 wordpress,证书使用 Let's Encrypt,SSL 证书更新使用 acme.sh

    问题: 使用 acme.sh 更新时,无法访问到.well-known 目录导致无法续期证书

    试过指定以下配置,访问不到

      location /.well-known {
        root /path/to/web;
      }
    
      location /.well-known/ {
        root /path/to/web;
      }
    
      location ~/.well-known {
        root /path/to/web;
      }
    
    

    现有配置:

      location / {
        proxy_pass http://wordpress;
        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_set_header X-Forwarded-proto https;
        proxy_redirect off;
      }
    
    
    PerFectTime
        1
    PerFectTime  
    OP
       Aug 25, 2020
    = =解决了,通过 try files 可以解决这个问题

    location /.well-known {
    try_files $uri $uri/ @backend;
    }

    location / {
    proxy_pass http://wordpress;
    }

    location @backend {
    proxy_pass http://wordpress;
    }
    PerFectTime
        2
    PerFectTime  
    OP
       Aug 25, 2020
    精简一下似乎也是可以的

    location /.well-known {
    try_files $uri $uri/ /;
    }

    location / {
    proxy_pass http://wordpress;
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5008 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 05:38 · PVG 13:38 · LAX 22:38 · JFK 01:38
    ♥ Do have faith in what you're doing.