我們的 Web 服務器正在偵聽 80 和 8080 端口,我希望特定路由只能通過端口 8080 使用,但拒絕嘗試使用端口 80 訪問該路由的所有用戶。我的routes.yamltesting-logging: path: /testing/logging controller: Test\Infrastructure\API\HTTP\Technical\LoggingController::handle methods: [GET]healthcheck: path: /healthcheck controller: Test\API\HTTP\Technical\HealthcheckController::handle methods: [GET]當然,還有更多的路線,但它們就像這些路線一樣。它是一個微服務,因此沒有任何用戶。我想通過自定義端口限制對某些路由的訪問。當然,其他路由必須像以前一樣使用標準端口。我試圖使用安全性:security: # https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers providers: in_memory: { memory: null } firewalls: dev: security: true anonymous: ~ methods: [POST] main: anonymous: lazy access_control: - { path: ^/healthcheck, roles: IS_AUTHENTICATED_ANONYMOUSLY, port: 8080 }
如何使用 Symfony 5 通過端口限制對某些路線的訪問?
慕桂英3389331
2022-09-17 21:26:44