Skip to content

refactor: isolate Spring Boot Actuator on dedicated internal port 8081#95

Merged
vitorhugo-java merged 2 commits intomasterfrom
copilot/refactor-actuator-internal-port
Apr 14, 2026
Merged

refactor: isolate Spring Boot Actuator on dedicated internal port 8081#95
vitorhugo-java merged 2 commits intomasterfrom
copilot/refactor-actuator-internal-port

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Summary

Moves the Spring Boot Actuator to a dedicated management port (8081) and replaces the previous token-based (X-Prometheus-Token header) authentication with Docker network-level isolation via infra_network.

Changes

src/main/resources/application.properties

  • Added management.server.port=8081 — Actuator now runs on a separate port from the main API (8080).
  • Removed app.monitoring.prometheus-token property (token auth is no longer used).

src/main/java/com/espacogeek/geek/config/SecurityConfig.java

  • Removed prometheusToken field (@Value("${app.monitoring.prometheus-token:}")).
  • Removed the custom X-Prometheus-Token header matcher and the fallback denyAll() for /actuator/**.
  • Added an explicit permitAll() for /actuator/** with a comment explaining:
    • The actuator is served exclusively on port 8081 (management port), so this rule on the main chain (port 8080) is a no-op.
    • Security is enforced via Docker infra_network isolation rather than token-based auth.
  • Removed unused java.security.MessageDigest import.

docker/docker-compose.yml

  • Updated the healthcheck URL from http://localhost:8080/actuator/healthhttp://localhost:8081/actuator/health to match the new management port.
  • Port 8081 is not listed in ports:, confirming it is never exposed to the host machine.

README.md

  • Replaced the "Monitoring Security" section (which described the token-based flow) with a "Monitoring" section documenting:
    • Actuator runs on port 8081, internal-only.
    • Prometheus scrapes via infra_network using espacogeek-jvm:8081 target — no auth header required.
  • Removed PROMETHEUS_SCRAPE_TOKEN from the Environment Variables example block.

Copilot AI and others added 2 commits April 14, 2026 19:28
- application.properties: add management.server.port=8081, remove prometheus token property
- SecurityConfig.java: replace token-based actuator auth with permitAll() + Docker isolation comment; remove unused MessageDigest import and prometheusToken field
- docker-compose.yml: update healthcheck to use port 8081; port 8081 not exposed to host
- README.md: rewrite Monitoring section to document port-isolated approach; remove PROMETHEUS_SCRAPE_TOKEN from env vars

Agent-Logs-Url: https://github.com/EspacoGeek-Teams/SpringAPI_EspacoGeek/sessions/d4565133-0637-4f24-afc4-f9c494a06cdf

Co-authored-by: vitorhugo-java <65777252+vitorhugo-java@users.noreply.github.com>
Copilot AI requested a review from vitorhugo-java April 14, 2026 19:33
@vitorhugo-java vitorhugo-java marked this pull request as ready for review April 14, 2026 20:20
Copilot AI review requested due to automatic review settings April 14, 2026 20:20
@vitorhugo-java vitorhugo-java merged commit dfd2eb6 into master Apr 14, 2026
3 checks passed
@vitorhugo-java vitorhugo-java deleted the copilot/refactor-actuator-internal-port branch April 14, 2026 20:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors monitoring by moving Spring Boot Actuator endpoints to a dedicated management port (8081) and removing token-based scrape authentication in favor of Docker network isolation (infra_network).

Changes:

  • Configure Actuator to run on management.server.port=8081 and remove the Prometheus scrape token property.
  • Simplify /actuator/** access rules in Spring Security by removing the X-Prometheus-Token header gate.
  • Update Docker healthcheck and README monitoring docs to target the new management port.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/main/resources/application.properties Sets management server port to 8081 and removes token config.
src/main/java/com/espacogeek/geek/config/SecurityConfig.java Removes token-based actuator authorization and permits /actuator/**.
docker/docker-compose.yml Points the container healthcheck at 8081/actuator/health.
README.md Updates monitoring documentation to reflect port 8081 + network isolation approach.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +83 to +89
// Actuator is served exclusively on the dedicated management port 8081
// (see management.server.port in application.properties), so this rule on
// the main port (8080) security chain is effectively a no-op. It is kept
// here for clarity: if /actuator paths ever reach this chain they are
// permitted, as security is handled via Docker network isolation
// (infra_network) rather than token-based authentication.
auth.requestMatchers("/actuator/**").permitAll();
# Network-level isolation (Docker infra_network) replaces token-based auth.
management.server.port=8081
management.endpoints.web.exposure.include=health,info,prometheus,metrics
management.endpoint.health.show-details=always
Comment thread docker/docker-compose.yml
Comment on lines 20 to 22
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
test: ["CMD", "curl", "-f", "http://localhost:8081/actuator/health"]
interval: 10s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants