笺注:这是在 LNMP一键安装包(lnmp_CentOS6.9) 的基础上进行的。
Nginx的版本:
[root@localhost ~]# nginx -v
nginx version: nginx/1.10.0
[root@localhost ~]# nginx -V
nginx version: nginx/1.10.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module
Nginx的主配置文件:
/usr/local/nginx/conf/nginx.conf
注释:在目录/usr/local/nginx/conf/vhost/下的.conf文件都会被加载。
添加 代理虚拟主机:(创建一个配置文件)
[root@localhost ~]# vi /usr/local/nginx/conf/vhost/test.zhuohua.store.conf
server
{
listen 80;
server_name test.zhuohua.store test2.zhuohua.store;
location / {
proxy_pass http://192.168.168.135:80/;
}
}
注释:当客户端访问test.zhuohua.store、test2.zhuohua.store的TCP 80端口时,反向代理到另外一台服务器(192.168.168.135)的TCP 80端口。
配置文件的属性:
重启Nginx:
在没有DNS服务器解析域名的情况下,Windows客户端可以在文件hosts里绑定,做硬解析测试:
客户端是直接访问Nginx代理服务器(192.168.168.130):
###############
###############
直接使用Nginx代理服务器的IP进行反向代理:
[root@localhost ~]# vi /usr/local/nginx/conf/nginx.conf
用到的代码:
location / {
proxy_pass http://192.168.168.135:80/;
}
注释:当客户端访问Nginx代理服务器(192.168.168.130)的TCP 80端口时,反向代理到另外一台服务器(192.168.168.135)的TCP 80端口。
重启Nginx:
客户端看到的效果:
#################################
#################################
亲,学习研究也要劳逸结合哦,来我微店逛逛,买点东西好好犒劳犒劳自己和家人吧^_^^_^
休闲零食传承世家风干牛肉干 手撕风干牛肉四川特产【非偏远地区满79包邮】
长虹办公室鼠标加热保暖桌垫毯电脑暖手桌面发热板电热台板写字台
飞科电熨斗蒸汽家用熨斗家用电烫斗蒸气手持迷你电熨斗FI9308包邮
新款男长款拉链潮男士钱包男士手拿包 商务皮夹钱夹-JKPJ1806
韩版定型斜挎单肩手提包SN-两层活动女包8874
|