美文网首页
nginx转发http请求

nginx转发http请求

作者: 薛延祥 | 来源:发表于2019-10-27 22:10 被阅读0次

    原路径: http://source.server.com/callback/test/test?username=xx

    转发到:http://10.1.9.1:8088/callback/test/test?username=xx

    配置如下:

    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 reload

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

    相关文章

      网友评论

          本文标题:nginx转发http请求

          本文链接:https://www.haomeiwen.com/subject/awwmvctx.html