Nginx 配置基于IP 地址的 Web 服务器
Nginx 配置基于IP 地址的 Web 服务器
1.配置网卡
nmcli connection modify ipv4.address 192.168.232.130/24 ipv4.gateway 192.168.232.2 ipv4.dns 192.168.232.2 ipv4.method manual
connection.autoconnect yes
2.添加ip地址
nmcli connection modify ens160 +ipv4.address 192.168.232.200/24
nmcli connection modify ens160 +ipv4.address 192.168.232.201/24
3.激活网关
nmcli connection up ens160
vim 200.conf
内容如下:
server{
server_name 192.168.232.200;
root /var/www/200/;
access_log /var/log/nginx/200/access.log;
error_log /var/log/nginx/200/error.log;
}
vim 201.conf
内容如下:
server
{
server_name 192.168.232.201;
root /var/www/201/;
access_log /var/log/nginx/201/access.log;
error_log /var/log/nginx/201/eror.log;
}
mkdir -p /var/www/201/
echo 200 > /var/www/200/index.html
mkdir /var/log/nginx/200/
mkdir -p /var/www/201/
echo 201 > /var/www/201/index.html
mkdir /var/log/nginx/201/