结合这篇文章一起:
环境准备
配置好两个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
server { 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
<!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>
测试:
到此这篇关于nginx基于ip的多虚拟主机实现的文章就介绍到这了,更多相关nginx ip多虚拟主机内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论