You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "ajaysehwal (via GitHub)" <gi...@apache.org> on 2025/05/27 06:22:41 UTC

[I] help request: Issue with APISIX Route Not Working via Proxy Domain [apisix]

ajaysehwal opened a new issue, #12260:
URL: https://github.com/apache/apisix/issues/12260

   ### Description
   
   Hi @Baoyuantop, we've currently deployed the APISIX gateway on a single server machine and are proxying it using a custom domain like api.random.in. I created a route in APISIX with URIs such as /global/posts/*, /global/users, and /global/users/*, and configured it to forward requests to the jsonplaceholder.typicode.com API using the proxy-rewrite plugin with a regex URI to strip the /global/ prefix. I also added a key-auth plugin with the API key passed via the X-API-KEY header or query parameter. The upstream is set to jsonplaceholder.typicode.com over HTTPS on port 443. Everything works fine when I access the gateway using the IP and port directly, such as http://<ip>:port/global/posts, but when I try accessing the same route using the domain https://api.random.in/global/posts (with the required headers), I receive a 404 Not Found error. Interestingly, if I access https://api.random.in/posts, it works and returns data from JSONPlaceholder. This behavior is confusing, and I’m 
 unsure whether it’s expected from APISIX or if I’ve misconfigured something. Could you please help me understand why the route with the /global prefix doesn’t work via the domain and guide me on how to fix it so it behaves the same way as it does via IP and port?
   
   please check my configs also for route ---- >  upsteam -> 
   {
     "nodes": [
       {
         "host": "jsonplaceholder.typicode.com",
         "port": 443,
         "weight": 1
       }
     ],
     "retries": 2,
     "timeout": {
       "connect": 60,
       "send": 60,
       "read": 60
     },
     "type": "roundrobin",
     "hash_on": "vars",
     "scheme": "https",
     "pass_host": "node",
     "name": "JSONPlaceholder API-0",
     "desc": "Fake Online REST API for Testing and Prototyping. Powered by JSONPlaceholder.",
     "keepalive_pool": {
       "idle_timeout": 60,
       "requests": 1024,
       "size": 10
     },
     "retry_timeout": 10
   }
    route --->   {
     "uris": [
       "/global/posts/*",
       "/global/users",
       "/global/users/*",
       "/global/posts"
     ],
     "name": "JSONPlaceholder API",
     "desc": "Fake Online REST API for Testing and Prototyping. Powered by JSONPlaceholder.",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE"
     ],
     "plugins": {
       "key-auth": {
         "header": "X-API-KEY",
         "hide_credentials": false,
         "query": "X-API-KEY"
       },
       "proxy-rewrite": {
         "headers": {
           "set": {
             "Host": "jsonplaceholder.typicode.com"
           }
         },
         "regex_uri": [
           "^/global/(.*)",
           "/$1"
         ],
         "use_real_request_uri_unsafe": false
       }
     },
     "service_id": "68345b632f638755c7fcf51e",
     "upstream_id": "CWS8hPD9AmUE5bU",
     "labels": {
       "endpoint": "68345b632f638755c7fcf51e"
     },
     "enable_websocket": true,
     "status": 1
   }
   
   ### Environment
   
   - APISIX version (run `apisix version`):
   - Operating system (run `uname -a`):
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


-- 
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.apache.org

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


Re: [I] help request: Issue with APISIX Route Not Working via Proxy Domain [apisix]

Posted by "ajaysehwal (via GitHub)" <gi...@apache.org>.
ajaysehwal commented on issue #12260:
URL: https://github.com/apache/apisix/issues/12260#issuecomment-2914901734

   Can we pass the ID of the route in headers, so we are unable to pass the Host header?


-- 
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


Re: [I] help request: Issue with APISIX Route Not Working via Proxy Domain [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #12260:
URL: https://github.com/apache/apisix/issues/12260#issuecomment-2921006272

   ```
   {
     "uri": "/*",
     "upstream": {
       "nodes": {
         "jsonplaceholder.typicode.com:80": 1
       },
       "type": "roundrobin",
       "pass_host": "node"
     }
   }
   ```


-- 
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


Re: [I] help request: Issue with APISIX Route Not Working via Proxy Domain [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #12260:
URL: https://github.com/apache/apisix/issues/12260#issuecomment-2914658674

   You can try tracing the full path of the request from the client to the APISIX gateway using `curl -v` or other tools to confirm what the actual URI was when the request arrived at APISIX.


-- 
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


Re: [I] help request: Issue with APISIX Route Not Working via Proxy Domain [apisix]

Posted by "ajaysehwal (via GitHub)" <gi...@apache.org>.
ajaysehwal commented on issue #12260:
URL: https://github.com/apache/apisix/issues/12260#issuecomment-2920009693

   Hi @Baoyuantop,
   Could you please provide an example route payload (either as a JSON object or a cURL command) for creating an APISIX route that proxies to jsonplaceholder.typicode.com?
   I’m looking for a setup where we don’t need to specify the Host header in the client request — ideally, the route should handle that internally. 
   It would be really helpful if you could share a working example. Thank you!
   
   


-- 
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


Re: [I] help request: Issue with APISIX Route Not Working via Proxy Domain [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on issue #12260:
URL: https://github.com/apache/apisix/issues/12260#issuecomment-2918015491

   > Can we pass the ID of the route in headers, so we are unable to pass the Host header?
   
   I don't get it. Can you explain it in detail?


-- 
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


Re: [I] help request: Issue with APISIX Route Not Working via Proxy Domain [apisix]

Posted by "ajaysehwal (via GitHub)" <gi...@apache.org>.
ajaysehwal closed issue #12260: help request: Issue with APISIX Route Not Working via Proxy Domain
URL: https://github.com/apache/apisix/issues/12260


-- 
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