【CentOS 7LNMP架构30】,设置nginx代理#

shallow丿ove


nginx代理

用户向代理服务器发送信息,web服务器接收到代理服务器的信息后,返回给代理服务器,最后发送到用户 线上环境是需要把网站域名解析到代理服务器上,这样用户的请求到了代理上,然后代理去帮用户到真实服务器获取数据,然后代理再把数据反馈给用户 类似于访问国外的服务器 类似于负载均衡

  • cd /usr/local/nginx/conf/vhost

  • vi proxy.conf server { listen 80; server name ask.apelearn.com;

      location \/
      {
      	proxy_pass http://121.201.9.155/;
      	proxy_set_header Host $host;
      	proxy_set_header X-Real-IP $remote_addr;
      	proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
      }
    

    }

[root@localhost ~]# cd /usr/local/nginx/conf/vhost/
[root@localhost vhost]# vi proxy.conf
      1 server
      2 {
      3         listen 80;
      4         server_name ask.apelearn.com;
      5 
      6         location /
      7         {
      8                 proxy_pass http://121.201.9.155/;
      9                 proxy_set_header Host   $host;
     10                 proxy_set_header X-Real-IP      $remote_addr;
     11                 proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
     12         }
     13 }
[root@localhost vhost]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost vhost]# /usr/local/nginx/sbin/nginx -s reload
[root@localhost vhost]# curl ask.apelearn.com/roobots.txt

[root@localhost vhost]# curl ask.apelearn.com/roobots.txt
#
# robots.txt for MiWen
#

User-agent: *

Disallow: /?/admin/
Disallow: /?/people/
Disallow: /?/question/
Disallow: /account/
Disallow: /app/
Disallow: /cache/
Disallow: /install/
Disallow: /models/
Disallow: /crond/run/
Disallow: /search/
Disallow: /static/
Disallow: /setting/
Disallow: /system/
Disallow: /tmp/
Disallow: /themes/
Disallow: /uploads/
Disallow: /url-*
Disallow: /views/
Disallow: /*/ajax/
[root@localhost vhost]# curl -x 127.0.0.1:80  ask.apelearn.com/roobots.txt
#
# robots.txt for MiWen
#

User-agent: *

Disallow: /?/admin/
Disallow: /?/people/
Disallow: /?/question/
Disallow: /account/
Disallow: /app/
Disallow: /cache/
Disallow: /install/
Disallow: /models/
Disallow: /crond/run/
Disallow: /search/
Disallow: /static/
Disallow: /setting/
Disallow: /system/
Disallow: /tmp/
Disallow: /themes/
Disallow: /uploads/
Disallow: /url-*
Disallow: /views/
Disallow: /*/ajax/

转载于:https://my.oschina.net/u/3892756/blog/3069415

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值