系统相关
首页 > 系统相关> > Nginx转发(代理)http请求

Nginx转发(代理)http请求

作者:互联网

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