server { #客户端访问的服务器主机和端口 listen 80; server_name localhost; location / { #需要代理的服务器 proxy_pass http://192.168.74.189:8000/; } }
例如这样, 可以直接访问 http://localhost:80/ 就能被代理访问到 http://192.168.74.189:8000/ 了 另外代理的服务器可以设置多个,负载均衡
http://localhost:80/
http://192.168.74.189:8000/