本机多域名配置 - zLulus/My_Note GitHub Wiki
方案1:反向代理
思路:
域名根据hosts文件找到本机,再根据nginx分发到不同的端口号
hosts文件
修改hosts文件,将指定域名指向本机
127.0.0.1 域名
nginx
1.下载nginx,注意下载windows版本
https://nginx.org/en/download.html
2.修改\conf\nginx.conf文件
server {
listen 80;
server_name 域名; #要访问的域名,我这里用的测试域名,如果有多个,用逗号分开
charset utf8;
location / {
proxy_pass http://127.0.0.1:本地的端口号; #映射到代理服务器,可以是ip加端口, 或url
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
3.运行nginx.exe
4.注意
修改config后需要重新运行
在windows系统下,先在任务管理器中关闭之前的nginx.exe,再重新启动,否则有问题
方案2:针对IIS
修改hosts文件
域名 127.0.0.1
修改IIS配置,指向域名