zhfish opened a new issue #5022:
URL: https://github.com/apache/apisix/issues/5022


   ### Issue description
   
   i use apisix to reverse proxy jenkins mirror,
   but proxy_rewrite ‘s  result is 301
   i hope proxy_rewrite = nginx's rewrite ?
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): 2.9
   - OS (cmd: `uname -a`): centos7
   
   
   ### Steps to reproduce
   
   - route
   ```
   {
     "uris": [
       "/*"
     ],
     "name": "jenkins-proxy",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "hosts": [
       "updates.jenkins-ci.org"
     ],
     "plugins": {
       "proxy-rewrite": {
         "regex_uri": [
           "/download/plugins/(.*)",
           "/jenkins/plugins/$1"
         ]
       }
     },
     "upstream_id": "366614512817669002",
     "labels": {
       "API_VERSION": "v1"
     },
     "status": 1
   }
   ```
   - upstream
   ```
   {
     "nodes": [
       {
         "host": "mirrors.ustc.edu.cn",
         "port": 80,
         "weight": 1
       }
     ],
     "timeout": {
       "connect": 76400,
       "read": 76400,
       "send": 76400
     },
     "type": "roundrobin",
     "scheme": "http",
     "pass_host": "node",
     "name": "jenkins-update"
   }
   ```
   
   ### Actual result
   
   ```
   # curl 
http://updates.jenkins-ci.org/download/plugins/42crunch-security-audit -vvv     
                                                 [12:46:58]
   * About to connect() to updates.jenkins-ci.org port 80 (#0)
   *   Trying 192.168.55.3...
   * Connected to updates.jenkins-ci.org (192.168.55.3) port 80 (#0)
   > GET /download/plugins/42crunch-security-audit HTTP/1.1
   > User-Agent: curl/7.29.0
   > Host: updates.jenkins-ci.org
   > Accept: */*
   >
   < HTTP/1.1 301 Moved Permanently
   < Content-Type: text/html
   < Content-Length: 166
   < Connection: keep-alive
   < Date: Thu, 09 Sep 2021 04:47:01 GMT
   < Location: 
http://mirrors.ustc.edu.cn/jenkins/plugins/42crunch-security-audit/
   < Server: APISIX/2.9
   <
   <html>
   <head><title>301 Moved Permanently</title></head>
   <body>
   <center><h1>301 Moved Permanently</h1></center>
   <hr><center>openresty</center>
   </body>
   </html>
   * Connection #0 to host updates.jenkins-ci.org left intact
   ```
   
   ### Error log
   
   It shouldn't be 301
   or
   I used the wrong plugins ?
   
   
   ### Expected result
   
   ```
   # curl 
http://updates.jenkins-ci.org/download/plugins/42crunch-security-audit -vvv     
                                                 [12:46:58]
   * About to connect() to updates.jenkins-ci.org port 80 (#0)
   *   Trying 192.168.55.3...
   * Connected to updates.jenkins-ci.org (192.168.55.3) port 80 (#0)
   > GET /download/plugins/42crunch-security-audit HTTP/1.1
   > User-Agent: curl/7.29.0
   > Host: updates.jenkins-ci.org
   > Accept: */*
   >
   < HTTP/1.1 301 Moved Permanently
   < Content-Type: text/html
   < Content-Length: 166
   < Connection: keep-alive
   < Date: Thu, 09 Sep 2021 04:47:01 GMT
   < Server: APISIX/2.9
   <
   <html>
   <head><title>Index of 
/jenkins/plugins/42crunch-security-audit/</title></head>
   <body>
   <h1>Index of /jenkins/plugins/42crunch-security-audit/</h1><hr><pre><a 
href="../">../</a>
   <a href="2.1/">2.1/</a>                                               
16-May-2020 13:42                   -
   <a href="2.2/">2.2/</a>                                               
16-May-2020 13:42                   -
   <a href="3.0/">3.0/</a>                                               
16-May-2020 13:42                   -
   <a href="3.1/">3.1/</a>                                               
18-May-2020 18:10                   -
   <a href="3.2/">3.2/</a>                                               
28-May-2020 00:30                   -
   <a href="3.3/">3.3/</a>                                               
08-Jun-2020 23:05                   -
   <a href="3.5/">3.5/</a>                                               
17-Jun-2020 13:10                   -
   <a href="3.6/">3.6/</a>                                               
11-Sep-2020 13:05                   -
   <a href="3.7/">3.7/</a>                                               
16-Sep-2020 18:26                   -
   <a href="3.8/">3.8/</a>                                               
06-Oct-2020 18:47                   -
   <a href="4.0/">4.0/</a>                                               
28-May-2021 10:43                   -
   <a href="latest/">latest/</a>                                            
28-May-2021 10:43                   -
   </pre><hr></body>
   </html>
   * Connection #0 to host updates.jenkins-ci.org left intact
   ```


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to