我们的 Web 服务器正在侦听 80 和 8080 端口,我希望特定路由只能通过端口 8080 使用,但拒绝尝试使用端口 80 访问该路由的所有用户。
我的routes.yaml
testing-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 }
30秒到达战场