NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
daimaosix
V2EX  ›  NGINX

请问一下反向代理中 url 参数如何反代到 url 路径呢?

  •  
  •   daimaosix · Oct 19, 2021 · 1537 views
    This topic created in 1679 days ago, the information mentioned may be changed or developed.

    源路径是:domain.b.com/sice/XXX

      location ^~ /icon/sice/ {
        proxy_redirect off;
        proxy_set_header Accept-Encoding '';
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://domain.b.com/sice/;
      }
    

    如何通过 domain.a.com/icon/sice/?id=123 传递给 domain.b.com/sice/123 呢?找了两天的资料了实在搞不定了。

    2 replies    2021-11-03 10:10:18 +08:00
    q15158012160
        1
    q15158012160  
       Oct 28, 2021
    rewrite ^/icon/(.*)$ http://domain.b.com/$1/$arg_id break;
    Alucns
        2
    Alucns  
       Nov 3, 2021
    试试
    proxy_pass http://domain.b.com/sice/$request_uri;
    我的服务器是这么操作
    upstream IndiaApiServer {
    server 192.168.0.1:8888 weight=1;
    }
    proxy_pass http://IndiaApiServer$request_uri;
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5986 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 211ms · UTC 03:08 · PVG 11:08 · LAX 20:08 · JFK 23:08
    ♥ Do have faith in what you're doing.