nginx 在docker中使用subpath的反向代理清漆

ruarlubt  于 5个月前  发布在  Nginx
关注(0)|答案(1)|浏览(45)

我遵循教程production-postgis-vector-tiles-caching。然而,当我试图设置pg_tileserve在反向代理下提供瓷砖和清漆也在反向代理下,我总是得到一个错误Error 503 Backend fetch failed。我的docker-compose看起来像

tiles:
 image: pramsey/pg_tileserv
 volumes:
   - ./config/pg_tileserv.toml:/etc/pg_tileserv.toml
 environment:
   - DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASS}@${POSTGRES_HOST}/${POSTGRES_DB}
   - TS_URLBASE=${VECTOR_TILES_URL}
   - TS_BASEPATH=/tiles
depends_on:
  db:
    condition: service_healthy
restart: always

cache:
 image: eeacms/varnish
 environment:
   BACKENDS: 'tiles:7800'
   DNS_ENABLED: 'false'
   COOKIES: 'true'
   PARAM_VALUE: '-p default_ttl=600'
   VARNISH_BACKEND_PATH: '/'
depends_on:
  tiles:
    condition: service_started
restart: always

nginx:
 image: nginx
 volumes:
   - ./sites-enabled:/etc/nginx/conf.d:ro  
 depends_on:
   - tiles
   - cache 
 ports:
   - "80:80"

字符串
我的nginx配置看起来像这样:

location /tiles {
    proxy_pass http://tiles;
    
}

location /cache {
    proxy_pass http://cache;
    
}


我如何修改我的清漆配置,考虑到我的瓷砖可以在http://localhost/tiles和清漆应该可以从http://localhost/cache

1l5u6lss

1l5u6lss1#

至于503错误,你可以使用varnishlog进行调试。请在你的Varnish容器中运行以下命令来弄清楚发生了什么:

docker exec -ti -u0 cache varnishlog -g request -q "RespStatus == 503"

字符串
请将相关日志输出附加到您的问题。
但是,您的docker-compose.yml似乎暴露了一些不一致:您的tiles服务器执行32772:7800端口转发。这意味着本地端口32772被转发到主机端口7800
cache容器的BACKENDS环境变量仍然引用tiles容器上的本地端口7800
您可以将tiles服务器的本地端口更改回7800,就像在tutorial中所做的那样。或者,如果出于某种原因,端口32772是正确的,请更改BACKENDS配置并将其指向端口32772

相关问题