nginx反向代理实验
接上节nginx搭建静态网页
现在使用openresty作为反向代理服务器;
1.下载openresty
官网:http://openresty.org/cn/
下载:http://openresty.org/cn/download.html
下载后编译,和nginx方法类似
安装到和nginx同目录下:
2.配置
打开/usr/local/openresty/nginx/conf/nginx.conf
添加 upstream(被代理的服务器)
openresty监听端口修改为81
proxy_pass http://local; 这里local和upstream后面的名字一致
../sbin/nginx -s reload
3.访问测试
http://192.168.192.142:81/
可以看出
server为:openresty/1.13.6.2
而访问http://192.168.192.142:80/
server为:nginx/1.14.2
在同一台机器上实验openresty代理nginx