在個人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; } }