Skip to content

Commit e0ac1ad

Browse files
committed
Bind GeoIP service to IPv6 for Railway private networking
1 parent 208da40 commit e0ac1ad

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

apps/geoip/.env.default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# GeoIP service
22
GEOIP_DB_DIR=/data/geoip
3+
HOST=::
34
PORT=8080
45

56
# Local API -> GeoIP service

apps/geoip/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ MAXMIND_LICENSE_KEY=<secret>
2929
MAXMIND_EDITION_IDS=GeoLite2-City GeoLite2-ASN
3030
GEOIP_DB_DIR=/data/geoip
3131
GEOIP_UPDATE_INTERVAL_HOURS=24
32+
HOST=::
3233
PORT=8080
3334
```
3435

@@ -57,10 +58,12 @@ GEOIP_SERVICE_URL=http://localhost:8083
5758

5859
Deploy this app as its own Railway service named `geoip`.
5960

61+
The service binds to `::` by default so Railway private networking can reach it in both new dual-stack environments and older IPv6-only ones.
62+
6063
The main API should use:
6164

6265
```env
63-
GEOIP_SERVICE_URL=http://geoip.railway.internal
66+
GEOIP_SERVICE_URL=http://geoip.railway.internal:8080
6467
```
6568

6669
Only the `geoip` service needs the MaxMind credentials.

apps/geoip/src/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Settings:
2222
license_key: str
2323
edition_ids: tuple[str, ...]
2424
db_dir: Path
25+
host: str
2526
update_interval_hours: int
2627
port: int
2728

@@ -48,7 +49,7 @@ def from_env(cls) -> "Settings":
4849
license_key=os.getenv("MAXMIND_LICENSE_KEY", "").strip(),
4950
edition_ids=_split_edition_ids(os.getenv("MAXMIND_EDITION_IDS")),
5051
db_dir=Path(os.getenv("GEOIP_DB_DIR", "/data/geoip")),
52+
host=os.getenv("HOST", "::").strip() or "::",
5153
update_interval_hours=int(os.getenv("GEOIP_UPDATE_INTERVAL_HOURS", "24")),
5254
port=int(os.getenv("PORT", "8080")),
5355
)
54-

apps/geoip/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ async def lookup(payload: LookupRequest) -> LookupResponse:
7070

7171
if __name__ == "__main__":
7272
settings = Settings.from_env()
73-
uvicorn.run("src.main:app", host="0.0.0.0", port=settings.port)
73+
uvicorn.run("src.main:app", host=settings.host, port=settings.port)

0 commit comments

Comments
 (0)