问题
Google App-Engine supports version-specific routing of requests as documented here. This is useful for example for testing a new version prior to deploying it. However, this may also be problematic. Say the new version includes security enhancements - there should be a way to prevent access to previous versions without deleting them completely (in order to allow for quick roll-back for instance). Could not find a way to disable previous versions. Is there a way to accomplish that ? Thanks.
回答1:
There is no way to disable default/soft/targeted routing on the appspot.com
domain.
But you could analyze the request's url structure and specifically reject requests with such undesired urls.
Or, if you're using a custom domain, reject all appspot.com
requests (see Disable default domain https://[project-id].appspot.com of Node JS on Google App Engine) and only leave the custom domain operational. Then the domain will be served following the service's traffic migration/splitting configuration which you'd manipulate in your deployments/rollback actions (you cannot route to a specific service version in the dispatch.yaml
file)
Update: indeed, as comments mentioned, blindly rejecting all appspot.com
requests isn't a good idea. Since URLs would need to be parsed to select the undesired ones it may be worthy to take the opportunity to redirect to canonical custom domain counterparts instead of just rejecting the requests.
来源:https://stackoverflow.com/questions/57545133/disabling-version-specific-urls-in-google-appengine