环境准备
配置好两个ip地址,给网络设备添加别名,绑定多个ip
ifconfig ens33:1 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255 up
配置
/usr/local/nginx/conf/extra/server_80.conf
bashserver { listen 192.168.1.50:80; server_name localhost; location /{ root html/server_50; index index.html; } }
配置完后:
检查:nginx -t
重新加载配置:nginx -s reload
创建server_50目录
/usr/local/nginx/html/server_50/index.html
html<!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to server_50!</h1> <p><em>Thank you for using nginx.</em></p> </body> </html>
测试: