nginx 反向代理

一:下载 nginx安装包

wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

二:解压nginx 安装包

tar -zxvf nginx-1.10.1.tar.gz

 三:编译 nginx

# cd nginx-1.10.1
./configure \
--prefix=/usr/local/nginx
# make && make install

  

 四:配置

#vim /usr/local/nginx/conf/nginx.conf

server {
        listen      80;
        server_name  192.168.1.10;
        location /test1/ {
                proxy_pass              http://192.168.1.12:8080/test1/;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                }
        location /test2/ {
                proxy_pass              http://192.168.1.11:8080/test2/;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
               }
       }

  

 

 

posted @ 2020-01-09 11:26  RoyFans  阅读(194)  评论(0编辑  收藏  举报