【CentOS 7LNMP架構32】,設置nginx代理#180108

hellopasswdnginx


nginx代理

用戶向代理服務器發送信息,web服務器接收到代理服務器的信息後,返回給代理服務器,最後發送到用戶 線上環境是須要把網站域名解析到代理服務器上,這樣用戶的請求到了代理上,而後代理去幫用戶到真實服務器獲取數據,而後代理再把數據反饋給用戶 相似於訪問國外的服務器 相似於負載均衡web

  • cd /usr/local/nginx/conf/vhostajax

  • 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;
      }

    }app

[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/

修改於 180108負載均衡

相關文章
相關標籤/搜索