Win下本地非80端口dns域名解析配置
win下本地非80端口dns域名解析配置
- what: win下本地非80端口dns域名解析配置
- where: win10
- when: 2022.4.24
- who: JRT
- why: 网上基本说的都是80端口解析,记录
- how:
1.原理
浏览器访问qq.com,直接dns先从本机hosts中读取地址是localhost(127.0.0.1 ),即http://qq.com=http://localhost:80,请求nginx,nginx通过配置文件转发localhost:8080,即http://qq.com=http://localhost:80=http://localhost:8080
2.前提
java安装(略)
nginx安装(略)
tomcat安装(略)
3.配置
nginx配置
vim nginx.conf
server {
listen 80;
server_name qq.com;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
tomcat配置
#以自身安装为例,删除D:\tomcat8\webapps\ROOT下所有文件,将自己的index.html放进去
本机hosts配置
vim C:\Windows\System32\drivers\etc\hosts
127.0.0.1 qq.com
刷新本机DNS
hosts配置好域名后需要刷新DNS
ipconfig /flushdns
查看DNS缓存内容变没变,检查是否配置成功
ipconfig /displaydns
启动服务
分别启动nginx、tomcat,浏览器访问http://qq.com
