在个人windows中经过vm搭建了一台虚拟机,经过桥接方式链接网络。
假设windows的IP: 192.168.1.100
虚拟机IP: 192.168.1.200(设置固定IP)
虚拟机运行着一个应用,监听3000端口,没有使用nginx以前,通常是经过http://192.168.1.200:3000/
这种方式来访问的,设置反向代理代理后能够经过http://example.com
直接访问。nginx
首先必须将example.com
解析到192.168.1.200
,windows
1)修改C:\Windows\System32\drivers\etc\hosts
2) 修改网关路由器的/etc/hosts
,windows机器不指定DNS服务器服务器
nginx反向代理配置网络
server { listen 80; server_name example.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:3000; } }