实验环境

192.168.186.129 centos7
本地windows

关闭防火墙和selinux

systemctl stop firewalld
setenforce 0

安装nginx、httpd

yum install nginx -y
yum install httpd -y
#在/etc/httpd/conf/httpd.conf修改httpd端口
listen 8080
#启动服务
systemctl start httpd

修改hosts文件

#打开windows的C:\Windows\System32\drivers\etc的hosts文件,追加一行
192.168.186.129 www.abctwf.com

编辑配置文件

vim /etc/nginx/nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name 192.168.186.129;
root /usr/share/nginx/html;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
proxy_pass http://127.0.0.1:8080;
}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}

测试

浏览器访问www.abctwf.com,即访问httpd首页