nginx转发http请求

原路径: http://source.server.com/callback/test/test?username=xx
转发到:http://10.1.9.1:8088/callback/test/test?username=xxphp

配置以下:html

server {
        listen       80;
        server_name source.server.com;

       # 匹配callback
        location /callback/ {
            proxy_pass http://10.1.9.1:8088;
        }

		# 默认其余
        location / {
           proxy_pass http://10.2.2.1:8088;
           # root   html;
           # index  index.html index.htm;
        }
		
		}

注意:在配置中http://10.1.9.1:8088,后面不用加任何目录,/callback/test/test,这一串都不须要加,/ 符号也不须要,
这是由于proxy_pass参数中若是不包含url的路径,则会将location的pattern识别的路径做为绝对路径。
重启:
./nginx -s reloadnginx

参考:https://www.php.cn/nginx/425693.htmlweb