Skip to content

Commit 001fc3d

Browse files
committed
Disallow http services on gateways with ACM cert
1 parent cd60d0a commit 001fc3d

File tree

1 file changed

+13
-2
lines changed
  • src/dstack/_internal/server/services/services

1 file changed

+13
-2
lines changed

src/dstack/_internal/server/services/services/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,24 @@ async def _register_service_in_gateway(
162162
)
163163
show_service_https = _should_show_service_https(run_spec, gateway_configuration)
164164
service_protocol = "https" if show_service_https else "http"
165-
router = _build_service_router_config(gateway_configuration, run_spec.configuration)
166165

167-
if configure_service_https and gateway_configuration.certificate is None:
166+
if (
167+
not show_service_https
168+
and gateway_configuration.certificate is not None
169+
and gateway_configuration.certificate.type == "acm"
170+
):
171+
# SSL termination is done globally at load balancer so cannot runs only some services via http.
172+
raise ServerClientError(
173+
"Cannot run HTTP service on gateway with ACM certificates configured"
174+
)
175+
176+
if show_service_https and gateway_configuration.certificate is None:
168177
raise ServerClientError(
169178
"Cannot run HTTPS service on gateway with no SSL certificates configured"
170179
)
171180

181+
router = _build_service_router_config(gateway_configuration, run_spec.configuration)
182+
172183
gateway_https = _get_gateway_https(gateway_configuration)
173184
gateway_protocol = "https" if gateway_https else "http"
174185

0 commit comments

Comments
 (0)