ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Nginx转发(代理)http请求

2022-05-06 16:03:38  阅读:93  来源: 互联网

标签:index set http header Nginx proxy 转发 buffers


nginx可以转发所有http/https的请求和响应。在配置文件配置如下代码即可:

    server {
        listen       8020;
        server_name  test;

        location / {
                index  index.html index.htm;
                index  proxy_buffer_size 64k;
                index  proxy_buffers  32 32k;
                index  proxy_busy_buffers_size 128k;
                index  proxy_set_header Host $host;
                index  proxy_set_header X-Real-IP $remote_addr;
                index  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://172.12.13.14:1500/;#http服务地址,复杂需要可配置upstream
        }
    }

配置完毕后,如上所示,则可以直接访问http://127.0.0.1:8020等同于访问http://172.12.13.14:1500/

标签:index,set,http,header,Nginx,proxy,转发,buffers
来源: https://www.cnblogs.com/cluyun/p/16229089.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有