You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/09/06 11:28:38 UTC

[GitHub] [apisix] ray-008 opened a new issue #4993: request help:

ray-008 opened a new issue #4993:
URL: https://github.com/apache/apisix/issues/4993


   ### Issue description
   
   当配置路由的cors插件的时,allow_origins 设置无法生效。
   ![070BCF868BBA2EFCA0DB77826C96E42F](https://user-images.githubusercontent.com/4973374/132210557-a0e1ffd9-6a3c-4933-a1fa-cb1ceb1e0e04.jpg)
   
   allow_origin 没有设置上
   ![image](https://user-images.githubusercontent.com/4973374/132210594-c38ccf27-e2ba-4d6b-ae05-7910045f4802.png)
   
   
   ### Environment
   
   - apisix version: 2.7
   - OS: centos 8
   - nginx:  1.14.1
   - etcd version:3.4.1
   - apisix-dashboard:2.7.1
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] ray-008 commented on issue #4993: request help: the allow_origins setting does not work when configuring the route's cors plugin

Posted by GitBox <gi...@apache.org>.
ray-008 commented on issue #4993:
URL: https://github.com/apache/apisix/issues/4993#issuecomment-913960370


   ok,我好像知道怎么回事了。
   
   假如自己的网站是 `www.a.com`
   
   #### 第一种情况:  当我设置`www.a.com` 的 `allow_origins` 成 `*` 时候
   ![image](https://user-images.githubusercontent.com/4973374/132274596-4404c749-ff33-4d3d-be92-aa57c3f30fe4.png)
   get请求 `www.a.com` 时,可以看到已经设置上了
   ![image](https://user-images.githubusercontent.com/4973374/132274716-8a1bd017-8cbf-4a9c-97e9-2a751e700714.png)
   
   -----
   #### 第二种情况:  当我设置`www.a.com` 的 `allow_origins` 为一个特定域名 `www.b.com` 后,直接访问 `www.a.com` 是不显示的:
   ![image](https://user-images.githubusercontent.com/4973374/132275541-8066206d-591f-493f-97f9-117508870097.png)
   
   ![image](https://user-images.githubusercontent.com/4973374/132275083-686ce4e7-5f3b-46bc-900a-16c6ca543c99.png)
   
   -----
   #### 第三种情况:  当我设置`www.a.com` 的 `allow_origins` 为一个特定域名 `www.b.com` 后,通过 `www.b.com` 访问 `www.a.com` 又显示设置上了。
   ![image](https://user-images.githubusercontent.com/4973374/132275404-1a54242a-5345-4b82-ae57-e03989e1a611.png)
   
   -----
   #### 第四种情况:  当我设置`www.a.com` 的 `allow_origins` 为一个特定域名 `www.b.com` 后,通过 `www.c.com` 访问 `www.a.com` ,跨域访问限制生效。
   ![image](https://user-images.githubusercontent.com/4973374/132275952-60b333a3-3c9d-4715-a7c2-6a943d8e9dff.png)
   
   
   apisix应该是有处理过这块逻辑,如果是自己访问自己就不会设置跨域相关属性?
   
   #### 还是非常感谢跟踪这个问题!cors插件是可以设置生效的。
   
   还有个问题,apisix支持设置返回的headers吗? 比如 Content-Security-Policy、X-Frame-Options、Set-Cookie等安全相关配置。 主要是想在一个地方统一设置,这样业务服务器就不用关心安全相关配置了。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] ray-008 commented on issue #4993: request help:

Posted by GitBox <gi...@apache.org>.
ray-008 commented on issue #4993:
URL: https://github.com/apache/apisix/issues/4993#issuecomment-913708489


   curl http://127.0.0.1/apisix/admin/routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' | jq
   
   ```
   {
     "action": "get",
     "node": {
       "nodes": [
         {
           "createdIndex": 134,
           "modifiedIndex": 442,
           "key": "/apisix/routes/371421588576273103",
           "value": {
             "uri": "/*",
             "methods": [
               "GET",
               "POST",
               "PUT",
               "DELETE",
               "PATCH",
               "HEAD",
               "OPTIONS",
               "CONNECT",
               "TRACE"
             ],
             "host": "www.xx.store",
             "name": "web",
             "status": 1,
             "id": "371421588576273103",
             "upstream": {
               "type": "roundrobin",
               "nodes": [
                 {
                   "port": 10001,
                   "weight": 1,
                   "host": "172.25.73.158"
                 }
               ],
               "scheme": "http",
               "timeout": {
                 "connect": 6,
                 "read": 6,
                 "send": 6
               },
               "pass_host": "pass"
             },
             "update_time": 1630930343,
             "plugins": {
               "cors": {
                 "max_age": -1,
                 "expose_headers": "*",
                 "allow_headers": "*",
                 "allow_origins": "https://www.xx.store",
                 "disable": false,
                 "allow_credential": false,
                 "allow_methods": "*"
               },
               "redirect": {
                 "http_to_https": true
               }
             },
             "desc": "web",
             "create_time": 1630914118
           }
         }
       ],
       "dir": true,
       "key": "/apisix/routes"
     },
     "count": 1
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] ray-008 commented on issue #4993: request help: the allow_origins setting does not work when configuring the route's cors plugin

Posted by GitBox <gi...@apache.org>.
ray-008 commented on issue #4993:
URL: https://github.com/apache/apisix/issues/4993#issuecomment-914161483


   非常感谢!正是我想要的


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] ray-008 closed issue #4993: request help: the allow_origins setting does not work when configuring the route's cors plugin

Posted by GitBox <gi...@apache.org>.
ray-008 closed issue #4993:
URL: https://github.com/apache/apisix/issues/4993


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Zheaoli commented on issue #4993: request help:

Posted by GitBox <gi...@apache.org>.
Zheaoli commented on issue #4993:
URL: https://github.com/apache/apisix/issues/4993#issuecomment-913704417


   would you mind giving the full config JSON content in this issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #4993: request help: the allow_origins setting does not work when configuring the route's cors plugin

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #4993:
URL: https://github.com/apache/apisix/issues/4993#issuecomment-914019135


   > 如果是自己访问自己就不会设置跨域相关属性
   
   The request will match the route first and the `cors` plugin will only be executed once the route has been matched. I see that you have set host in your route conf.
   
   
   > 还有个问题,apisix支持设置返回的headers吗?
   
   see: https://github.com/apache/apisix/blob/master/docs/zh/latest/plugins/response-rewrite.md


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #4993: request help: the allow_origins setting does not work when configuring the route's cors plugin

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #4993:
URL: https://github.com/apache/apisix/issues/4993#issuecomment-913919329


   > allow_origin 没有设置上
   
   what method of this request?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #4993: request help: the allow_origins setting does not work when configuring the route's cors plugin

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #4993:
URL: https://github.com/apache/apisix/issues/4993#issuecomment-913920333


   It would be good to give information on what is requested and expected, which I can reproduce


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org