环境:本地外网ip:123.58.251.1661、配置index.html网页[root@host-10-1-1-161 conf.d]# cat /web/sing/index.htmlwww.test1.com
2、配置conf.d目录下配置文件[root@host-10-1-1-161 conf.d]# pwd/etc/nginx/conf.d[root@host-10-1-1-161 conf.d]# lstest1.conf test2.conf test3.conf[root@host-10-1-1-161 conf.d]# cat test1.conf server {listen 8083;server_name 127.0.0.1:8083;location / {root /web/sing/;index index.html index.htm;}}[root@host-10-1-1-161 conf.d]# cat test3.conf upstream abc.com { server 127.0.0.1:8083 fail_timeout=20s; #server 127.0.0.1:8086 fail_timeout=20s; #ip_hash; 打开后就会访问到一台上 }server { listen 80; server_name oa.test.com; location / { #反向代理的地址 proxy_pass http://abc.com; }}3、配置hosts[root@host-10-1-1-161 conf.d]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6123.58.251.166 oa.test.com [root@host-10-1-1-161 conf.d]# nginx -s reload4、开始访问 注意:要从百度访问必须注册备案域名[root@host-10-1-1-161 ~]# curl http://oa.test.comwww.test1.com