如何在现有的Nginx配置上设置Titiller以自定义root_path

juzqafwq  于 2023-08-03  发布在  Nginx
关注(0)|答案(1)|浏览(131)

给定一个Geonode示例,Nginx使用这个config,我想添加一个titiler的上游,我有一个compose文件:

version: '2.2'

services:
  titiler:
    image: ghcr.io/developmentseed/titiler:latest
    container_name: titiler
    environment:
      - PORT=8081
      - WORKERS_PER_CORE=1
      - TITILER_API_ROOT_PATH=/api/v1/titiler

字符串
使用新的nginx配置

(...)
location /api/v1/titiler {
    set $upstream titiler:8081;
    proxy_pass http://$upstream;
    proxy_set_header HOST $host;
    proxy_set_header Referer $http_referer;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}


问题是,在nginx容器内,当我尝试curl titiler:8081/api/v1/titiler时,我得到了curl titiler:8081/api/v1/titiler {"detail":"Not Found"},问题似乎是titiler没有使用给定的ROOT_PATH的问题,我的问题是,因为它显然是tiler的问题,更确切地说是fastapi,有没有办法在现有服务器上配置titiler?
在瓷砖容器内

from titiler.application.main import api_settings
print(api_settings.root_path)


/API/v1/titiller
我已经在上面描述了我所做的步骤,但没有取得任何进展

lkaoscv7

lkaoscv71#

location /api/v1/titiler {
    set $upstream titiler:8081;
    rewrite ^/api/v1/titiler(.*)$ $1 break;
    proxy_pass http://$upstream;
    proxy_set_header HOST $host;
    proxy_set_header Referer $http_referer;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}```

字符串

相关问题