hellopasswdnginx
用户向代理服务器发送信息,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负载均衡