续我的上篇博文:https://mp.csdn.net/postedit/89536727。即本篇博文是在上篇博文修改完之后的nginx.conf文件中进行修改的。
nginx服务虚拟主机的配置
[root@server1 ~]# vim /usr/local/nginx/conf/nginx.conf #将之前在该配置文件最后编写的server{}模块修改为如下的样子
137 server {
138 listen 80;
139 server_name xin.westos.org;
140 #set_real_ip_from 172.25.83.0/24;
141 #real_ip_header X-Forwarded-For;
142 #real_ip_recursive on;
143
144 location / {
145 #return 200 "client real ip: $remote_addr\n";
146 root /web;
147 index index.html;
148 }
149 }
150 }
[root@server1 ~]# mkdir /web
[root@server1 ~]# echo xin.westos.org > /web/index.html
利用curl命令进行验证:xin.westos.org:输出/web目录下的index.html文件中的内容。
[root@server1 ~]# vim /etc/hosts #编辑本地解析文件
172.25.83.1 xin.westos.org
[root@server1 ~]# curl xin.westos.org
xin.westos.org