我将Nginx安装在192.168.220.129这台虚拟机上,并在本地host文件中配置 www.hz1202.com 指向192.168.220.129html
#要代理到哪一个服务器的哪一个端口 upstream hz{ server 192.168.220.129:8080; } server{ listen 80; #访问服务器的域名 server_name www.hz1202.com; location / { #代理到那个服务器 这里http://hz 指的是上面upstream 中的 hz proxy_pass http://hz; index index.html index.htm; }
通过以上配置,当访问http:// www.hz1202.com时,实际访问的是192.168.220.129这台服务器的8080端口nginx