在本地的Windows环境下使用nginx,双击nginx.exe启动。(保证conf\nginx.conf中配置的端口未被占用)html
查看nginx是否运行:nginx
修改conf\nginx.conf, 添加upstream esl, 并使用于proxy_pass:ui
#其余配置 http { upstream esl { server 192.168.100.117:9999 weight=3; server 192.168.100.118:9999 weight=1; } #其余配置 server { listen 8888; server_name localhost; location / { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, C ontent-Type, Accept"; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; root html/build/dist; index index.html index.htm; } location /zk/ { rewrite ^/zk/(.*)$ /$1 break; proxy_pass http://esl; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
加载配置:code
nginx.exe -s reload
配置完成后,访问http://localhost:8888,实际访问esl中配置的两台机器。server
PS: nginx.exe的全部操做htm
关闭nginx,只须要blog
nginx.exe -s quit