0

This is the nginx configuration:

  location /debug {
    proxy_pass http://127.0.0.1:32339/;
    proxy_set_header Host $http_host;
  }

Expected visits http://127.0.0.1:80/debug/a/b Proxy to http://127.0.0.1:32339/a/b

The actual server returned 301 redirects to http://127.0.0.1:80/a/b.

I don't want him to do this, it should act as an agent http://127.0.0.1:32339/a/b enter image description here

Configure proxy_ pass http://127.0.0.1:32339/; Remove the end, it will no longer redirect, but /debug still exists

  location /debug {
    proxy_pass http://127.0.0.1:32339;
    proxy_set_header Host $http_host;
  }

nginx version 1.23.3

Please help me, thanks;

I have tried this configuration before, but the result is still the same

  location /debug/ {
    proxy_pass http://127.0.0.1:32339;
    rewrite /debug/(.*) /$1 break;
  }

Using curl to execute results

[root@node1 conf.d]# curl --location http://127.0.0.1:80/debug/a/b
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.23.3</center>
</body>
</html>
[root@node1 conf.d]# 

何呵呵
  • 25
  • 3

1 Answers1

0

Have you tried this?

 location ~ ^/debug(.*) {
    proxy_pass http://127.0.0.1:32339$1;
    proxy_set_header Host $http_host;
  }
IVO GELOV
  • 13,496
  • 1
  • 17
  • 26