## in /etc/hosts
# 127.0.0.1 alternatives.domain.local user_alternatives.domain.local admin_alternatives.domain.local

# tcp:
#   routers:
#     next_traefik_router:
#       entryPoints:
#         - web
#       # rule: "HostSNI(`*`)"
#       # rule: "!HostSNI(`alternatives.ai-tools-online.xyz`)"
#       rule: "HostSNI(`auth.weloveparty.ai-tools-online.xyz`)"
#       service: next_traefik_service
#       tls:
#          passthrough: true
#   services:
#     next_traefik_service:
#       loadBalancer:
#         servers:
#           - address: 144.202.109.163:810
#           # - address: 127.0.0.1:810

http:
  routers:
    fuck:
      entryPoints:
        - web
        - websecure
      rule: "PathPrefix(`/fuck/`)"
      service: fuck_service
    expo_shop:
      entryPoints:
        - web
        - websecure
      rule: "HostRegexp(`(.*)expo_shop(.*)`)"
      middlewares:
        - cros_allow_all
      service: expo_shop_service
    # next_traefik_router:
    #   entryPoints:
    #     - web
    #     - websecure
    #   # rule: "!Host(`alternatives.ai-tools-online.xyz`)"
    #   rule: "HostRegexp(`(.*)weloveparty(.*)`)"
    #   service: next_traefik_service
    next_traefik_router_for_style_shop:
      entryPoints:
        - web
        - websecure
      rule: "HostRegexp(`(.*)style_shop(.*)`)"
      service: next_traefik_service_for_style_shop
    next_traefik_router_for_play_with_css:
      entryPoints:
        - web
        - websecure
      rule: "HostRegexp(`(.*)yingshaoxo.xyz`) && PathPrefix(`/play-with-css/`)"
      middlewares:
        - cros_allow_all
      service: next_traefik_service_for_play_with_css
    next_traefik_router_for_yingshaoxo_xyz:
      entryPoints:
        - web
        - websecure
      rule: "HostRegexp(`(.*)yingshaoxo.xyz`) && !PathPrefix(`/play-with-css/`)"
      middlewares:
        - cros_allow_all
      service: next_traefik_service_for_yingshaoxo_xyz
    its_alternative_router_for_visitor_operations:
      entryPoints:
        - web
        - websecure
      # rule: "(Host(`alternatives.ai-tools-online.xyz`) || Host(`alternatives.domain.local`)) && PathPrefix(`/it_has_alternatives/`)"
      rule: "Host(`alternatives.ai-tools-online.xyz`)"
      middlewares:
        - cros_allow_all
      service: backend_service_for_visitor
    yppm_community_router:
      entryPoints:
        - web
        - websecure
      rule: "Host(`ask.ai-tools-online.xyz`)"
      middlewares:
        - cros_allow_all
      service: yppm_community_service
    yppm_ytorrent_router:
      entryPoints:
        - web
        - websecure
      rule: "Host(`ytorrent.ai-tools-online.xyz`)"
      middlewares:
        - cros_allow_all
      service: yppm_ytorrent_service
    vpn_router:
      entryPoints:
        - web
        - websecure
      rule: "Host(`vpn.ai-tools-online.xyz`)"
      middlewares:
        - localhost
        - cros_allow_all
      service: vpn_service
    lab_router:
      entryPoints:
        - web
        - websecure
      rule: "Host(`lab.ai-tools-online.xyz`)"
      middlewares:
        - localhost
        - cros_allow_all
      service: lab_service
    bbs_router:
      entryPoints:
        - web
        - websecure
      rule: "Host(`bbs.ai-tools-online.xyz`)"
      middlewares:
        - localhost
        - cros_allow_all
      service: bbs_service
    message_router:
      entryPoints:
        - web
        - websecure
      rule: "Host(`message.ai-tools-online.xyz`)"
      middlewares:
        - localhost
        - cros_allow_all
      service: message_service
    chat_router:
      entryPoints:
        - web
        - websecure
      rule: "Host(`chat.ai-tools-online.xyz`)"
      middlewares:
        - localhost
        - cros_allow_all
      service: chat_service

  middlewares:
    localhost:
      headers:
        customRequestHeaders:
          X-Real-IP: "127.0.0.1"
    cros_allow_all:
      headers:
        accessControlAllowMethods: "*"
        accessControlAllowHeaders: "*"
        accessControlAllowOriginList: "*"
        accessControlMaxAge: 100
        addVaryHeader: true
    my_grpcweb:
      grpcWeb:
        allowOrigins:
          - "*"
    #my_jwt_auth:
    #    forwardAuth:
    #      address: "http://127.0.0.1:5550/v1/jwt_auth_gateway/"
    #      authResponseHeaders:
    #          - "email" # jwt_auth_gateway will put this header to the original request
    #my_admin_jwt_auth:
    #    forwardAuth:
    #      address: "http://127.0.0.1:5550/v1/admin_jwt_auth_gateway/"
    #      authResponseHeaders:
    #          - "email" # jwt_auth_gateway will put this header to the original request

  services:
    fuck_service:
      loadBalancer:
        servers:
          - url: http://pornhub.com
    expo_shop_service:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:3000
    # next_traefik_service:
    #   loadBalancer:
    #     servers:
    #       - url: http://127.0.0.1:810
    next_traefik_service_for_style_shop:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:811
    next_traefik_service_for_play_with_css:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:9191
    next_traefik_service_for_yingshaoxo_xyz:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:9190
    backend_service_for_visitor:
      loadBalancer:
        servers:
          # - url: http://it_has_alternatives:5551
          # - url: http://host.docker.internal:5551
          - url: http://127.0.0.1:5551
        passHostHeader: true
    yppm_community_service:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:54321
        passHostHeader: true
    yppm_ytorrent_service:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:1111
        passHostHeader: true
    vpn_service:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:14141
        passHostHeader: true
    lab_service:
      loadBalancer:
        servers:
          - url: http://localhost:19998
        passHostHeader: true
    bbs_service:
      loadBalancer:
        servers:
          - url: http://localhost:7071
        passHostHeader: true
    message_service:
      loadBalancer:
        servers:
          - url: http://localhost:8899
        passHostHeader: true
    chat_service:
      loadBalancer:
        servers:
          - url: http://127.0.0.1:8991
        passHostHeader: true
