nginx做反向代理参数处理
发布于 11 年前 作者 xiuxu123 9113 次浏览 最后一次编辑是 8 年前

我在用nginx做反向代理的时候,不知道参数怎么处理? 我的配置信息:

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;
            #index  index.html index.htm;
  		
            proxy_pass   http://localhost:3000;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        location /detail/\* {
            proxy_pass   http://localhost:3000/detail/85;
        }
	}

当我访问:localhost的时候是正常的,我访问localhost:80/detail/85的时候其实也正常,是因为:

  location /detail/\* {
      proxy_pass   http://localhost:3000/detail/85;   <---这里我写死了
  }

所以请问有没有怎么处理参数的方法啊???

2 回复

哈哈,你只需要写第一个就可以了,可以匹配所有,不行你试试。

谢谢您了,这样可以

回到顶部