Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to enable the cross-domain request CORS function of OpenStack Api

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about how to turn on the cross-domain request CORS function of OpenStack Api. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.

If you plan to use the openstack interface (such as jstack) in js, you will encounter the problem of cross-domain requests from js. The solution is to add header information such as Access-Control-Allow-Origin: * to the response of openstack api.

# # reverse proxy if a reverse proxy is configured for api, please refer to: http://enable-cors.org/server.html

# # configuring wsgi almost all openstack api uses wsgi service. We can set CORS information at the wsgi layer.

First install a python module

Pip install wsgicors

# Let Keystone support CORS editing / etc/keystone/keystone-paste.ini, and add the following:

[filter:cors] use = egg:wsgicors#middlewarepolicy = openopen_origin = * open_headers = * open_methods = * open_maxage = 86400

Then, add cors at the beginning of each pipeline, for example:

[pipeline:public_api] pipeline = cors stats_monitoring sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body_v2 json_body ec2_extension user_crud_extension public_ service [pipe line:admin_api] pipeline = cors sizelimit url_normalize build_auth_context token_auth admin_token_auth xml_body_v2 json_body ec2_extension s3_extension crud_extension admin_ service [pipe: api_v3] pipeline = cors stats_reporting sizelimit url_normalize build_auth_context token_ Auth admin_token_auth xml_body_v3 json_body ec2_extension_v3 s3_extension simple_cert_extension revoke_extension service_ v3 [places: public_version_api] pipeline = cors sizelimit url_normalize xml_body public_version_ service [rooms: admin_version_api] pipeline = cors sizelimit url_normalize xml_body admin_version_service

Finally restart the service

Service keystone restart

# Let nova-api support CORS editing / etc/nova/api-paste.ini, and add the following:

[filter:cors] use = egg:wsgicors#middlewarepolicy = openopen_origin = * open_headers = * open_methods = * open_maxage = 86400

Then, add cors at the beginning of each pipeline, for example:

[composite:openstack_compute_api_v2] use = call:nova.api.auth:pipeline_factorynoauth = cors compute_req_id faultwrap sizelimit noauth ratelimit osapi_compute_app_v2keystone = cors compute_req_id faultwrap sizelimit authtoken keystonecontext ratelimit osapi_compute_app_v2keystone_nolimit = cors compute_req_id faultwrap sizelimit authtoken keystonecontext osapi_compute_app_ v2 [composite: openstack_compute_api_v21] use = call:nova.api.auth:pipeline_factory_v21noauth = cors request_id faultwrap sizelimit noauth osapi_compute_app _ v21keystone = cors request_id faultwrap sizelimit authtoken keystonecontext osapi_compute_app_ v21 [composite: openstack_compute_api_v3] use = call:nova.api.auth:pipeline_factory_v21noauth = cors request_id faultwrap sizelimit noauth_v3 osapi_compute_app_v3keystone = cors request_id faultwrap sizelimit authtoken keystonecontext osapi_compute_app_v3

Finally restart nova-api

Service nova-api restart after reading the above, do you have any further understanding of how to turn on the cross-domain request CORS function of OpenStack Api? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report