有一种场景,我们的server部署在公网,但我们局域网的主机都不能直连访问server
比如只有主机A可以连接访问server,那么就可以在主机A部署nginx
然后内网中的主机agent都把请求数据发送到主机A代理程序nginx,再由nginx代理转发上报给server,如此就实现了agent给server上报数据
主机A的nginx配置如下,我们的server主机是192.168.1.2:
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location /wgcloud/ { proxy_pass http://192.168.1.2:9999/wgcloud/; proxy_cookie_path /wgcloud/ /; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
配置好后,我们重启下nginx
/usr/sbin/nginx -s reload
标签:直连,主机,agent,server,nginx,html,proxy,内网 From: https://www.cnblogs.com/wanghouhou/p/16873175.html