Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing CORS config across all virtual_hosts #9924

Closed
nathanhleung opened this issue Feb 4, 2020 · 6 comments
Closed

Sharing CORS config across all virtual_hosts #9924

nathanhleung opened this issue Feb 4, 2020 · 6 comments
Labels
question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently

Comments

@nathanhleung
Copy link

Short Description

I currently specify the same CORS config under each virtual_host. Is it possible to set the CORS config once and share it across all virtual_hosts?

Extended Description

I'm currently using Envoy to route requests to gRPC services based on the host header.

Here's the relevant part of my config, under static_resources.listeners[].filter_chains.filters['envoy.http_connection_manager'].config.route_config:

virtual_hosts:
  - name: server1
    domains:
      - $SERVER1_EXTERNAL_HOST
    routes:
      - match: { prefix: "/" }
        route:
          cluster: server1
          max_grpc_timeout: 0s
    cors:
      allow_origin_string_match:
        safe_regex:
          google_re2:
            max_program_size: 100
          regex: ".*"
      allow_methods: GET, PUT, DELETE, POST, OPTIONS
      allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,authorization,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
      max_age: "1728000"
      expose_headers: grpc-status,grpc-message
  - name: server2
    domains:
      - $SERVER2_EXTERNAL_HOST
    routes:
      - match: { prefix: "/" }
        route:
          cluster: server2
          max_grpc_timeout: 0s
    cors:
      allow_origin_string_match:
        safe_regex:
          google_re2:
            max_program_size: 100
          regex: ".*"
      allow_methods: GET, PUT, DELETE, POST, OPTIONS
      allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,authorization,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
      max_age: "1728000"
      expose_headers: grpc-status,grpc-message

I use the same CORS config for both services -- is it possible to specify that config once somewhere else and have it apply for all virtual_hosts?

@mattklein123 mattklein123 added the question Questions that are neither investigations, bugs, nor enhancements label Feb 5, 2020
@mattklein123
Copy link
Member

cc @dschaller @derekargueta for comment.

@derekargueta
Copy link
Member

derekargueta commented Feb 5, 2020

This would be achievable by moving the CORS to per_filter_config, which could then be configured at the global, virtual host, or route level.

My initial attempt if anyone wants to revive it, my plate is a little full at the moment: #9324

@nathanhleung
Copy link
Author

I'm happy to give it a shot but not exactly sure what's going on. What needs to be done?

@nathanhleung
Copy link
Author

I ended up using YAML anchors.

@stale
Copy link

stale bot commented Mar 26, 2020

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Mar 26, 2020
@stale
Copy link

stale bot commented Apr 2, 2020

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions.

@stale stale bot closed this as completed Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions that are neither investigations, bugs, nor enhancements stale stalebot believes this issue/PR has not been touched recently
Projects
None yet
Development

No branches or pull requests

3 participants