Skip to content

Commit 5b7fa72

Browse files
geospatial-jeffmoradology
authored andcommitted
add nginx service to docker-compose, proxy pgstac and sqlalchemy apps
1 parent 7ba0a40 commit 5b7fa72

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
version: '3'
22
services:
3+
nginx:
4+
image: nginx
5+
ports:
6+
- 80:80
7+
volumes:
8+
- ./nginx.conf:/etc/nginx/nginx.conf
9+
depends_on:
10+
- app-pgstac
11+
- app-sqlalchemy
12+
command: ["nginx-debug", "-g", "daemon off;"]
13+
314
app-sqlalchemy:
415
container_name: stac-fastapi-sqlalchemy
516
image: stac-utils/stac-fastapi
@@ -19,6 +30,7 @@ services:
1930
- POSTGRES_HOST_WRITER=database
2031
- POSTGRES_PORT=5432
2132
- WEB_CONCURRENCY=10
33+
- UVICORN_ROOT_PATH=/api/v1/sqlalchemy
2234
ports:
2335
- "8081:8081"
2436
volumes:
@@ -50,6 +62,7 @@ services:
5062
- DB_MIN_CONN_SIZE=1
5163
- DB_MAX_CONN_SIZE=1
5264
- USE_API_HYDRATE=${USE_API_HYDRATE:-false}
65+
- UVICORN_ROOT_PATH=/api/v1/pgstac
5366
ports:
5467
- "8082:8082"
5568
volumes:

nginx.conf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
events {}
2+
3+
http {
4+
server {
5+
listen 80;
6+
7+
location /api/v1/pgstac {
8+
rewrite ^/api/v1/pgstac(.*)$ $1 break;
9+
proxy_pass http://app-pgstac:8082;
10+
proxy_set_header HOST $host;
11+
proxy_set_header Referer $http_referer;
12+
proxy_set_header X-Forwarded-For $remote_addr;
13+
proxy_set_header X-Forwarded-Proto $scheme;
14+
}
15+
16+
location /api/v1/sqlalchemy {
17+
rewrite ^/api/v1/sqlalchemy(.*)$ $1 break;
18+
proxy_pass http://app-sqlalchemy:8081;
19+
proxy_set_header HOST $host;
20+
proxy_set_header Referer $http_referer;
21+
proxy_set_header X-Forwarded-For $remote_addr;
22+
proxy_set_header X-Forwarded-Proto $scheme;
23+
}
24+
25+
location / {
26+
proxy_redirect off;
27+
}
28+
}
29+
}

stac_fastapi/pgstac/stac_fastapi/pgstac/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def run():
8888
port=settings.app_port,
8989
log_level="info",
9090
reload=settings.reload,
91+
root_path=os.getenv("UVICORN_ROOT_PATH", ""),
9192
)
9293
except ImportError:
9394
raise RuntimeError("Uvicorn must be installed in order to use command")

stac_fastapi/sqlalchemy/stac_fastapi/sqlalchemy/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""FastAPI application."""
2+
import os
3+
24
from stac_fastapi.api.app import StacApi
35
from stac_fastapi.api.models import create_get_request_model, create_post_request_model
46
from stac_fastapi.extensions.core import (
@@ -55,6 +57,7 @@ def run():
5557
port=settings.app_port,
5658
log_level="info",
5759
reload=settings.reload,
60+
root_path=os.getenv("UVICORN_ROOT_PATH", ""),
5861
)
5962
except ImportError:
6063
raise RuntimeError("Uvicorn must be installed in order to use command")

0 commit comments

Comments
 (0)