使用nginx访问wgcloud运维监控系统
1.nginx配置如下:
比如nginx部署172.17.188.27主机上,server也在172.17.188.27上,访问地址如:http://172.17.188.27/wgcloud
提示:v3.4.7开始 访问地址已经不需要加/wgcloud了
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://127.0.0.1:9999; #root html; #index index.html index.htm; } #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; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
2.记得agent的配置文件项serverUrl的80端口也要写上,如下
agent如果依然可以上报数据,就可以不用修改如下配置
#wgcloud-server端访问地址,端口一定要写,即使是80也要写哈 serverUrl=http://172.17.188.27:80
3.https访问时候需要注意,配置有所不同,修改如下
location / { proxy_pass http://127.0.0.1:9999; proxy_redirect http:// https://; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; }
4.wss反向代理使用说明,在使用https时候页面会启用wss协议,端口为443,前端访问变为如wss:domain:443/ws,nginx接入443端口后配置如下
location /ws { proxy_pass http://127.0.0.1:9998; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }