尝试使用nginx的反向代理

在个人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

  1. 首先必须将example.com解析到192.168.1.200windows

    1)修改C:\Windows\System32\drivers\etc\hosts
    2) 修改网关路由器的/etc/hosts,windows机器不指定DNS服务器服务器

  2. 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;
        }
}
  • THE END
相关文章
相关标签/搜索