Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize load balancing of Multi-geoserver Services by nginx

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how nginx implements load balancing of multi-geoserver services". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to achieve load balancing of multi-geoserver services in nginx" can help you solve the problem.

Overview

In order to improve the access speed of services, reduce the pressure on geoserver services, and avoid problems in service nodes that affect the stability of service access, we usually deploy multiple geoserver to solve the problem, but after deploying multiple geoserver, we need a unified interface to provide for use. Nginx can meet this demand very well. This article describes how to achieve load balancing of multi-geoserver services through nginx.

Realize the effect

Achieve 1. Multi-geoserver deployment

In order to keep the service of geoserver consistent, we first configure a geoserver service, and then replicate and clone the deployed Tomcat. This article replicates two (a total of three geoserver), modifies the ports of Tomcat so that the three ports do not conflict, and then starts three Tomcat respectively.

2. Nginx configuration

Modify the nginx.conf file with the following configuration information:

# user nobody;worker_processes 1 the errorless log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream # log_format main'$remote_addr-$remote_user [$time_local] "$request" #'$status $body_bytes_sent "$http_referer" #'"$http_user_agent"$http_x_forwarded_for"; # access_log logs/access.log main; sendfile on; # tcp_nopush on; # keepalive_timeout 0; keepalive_timeout 65 # gzip on; # reverse proxy configuration upstream server_list {# this is the access path of tomcat server localhost:8081; server localhost:8082; server localhost:8083;} server {listen 80; server_name localhost; location / {add_header 'Access-Control-Allow-Origin' $http_origin Add_header 'Access-Control-Allow-Credentials'' true'; add_header 'Access-Control-Allow-Methods'' GET, POST, OPTIONS' Add_header 'Access-Control-Allow-Headers'' DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'; add_header 'Access-Control-Expose-Headers'' Content-Length,Content-Range' If ($request_method = 'OPTIONS') {add_header' Access-Control-Max-Age' 1728000; add_header 'Content-Type'' text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204;} root html; proxy_pass http://server_list; Index index.html index.htm;} error_page 500 502 503 504 / 50x.htl; location = / 50x.html {root html;}}

Once nginx is configured, start nginx.

3. Front-end call

According to the above configuration, the port of nginx is 80, so the address of geoserver is http://localhost/geoserver,. The calling code in ol is as follows:

OpenLayers map preview const options = {center: [52102781.07568731, 4456849.777083951], zoom: 3, minZoom: 0, maxZoom: 18} const base = new ol.layer.Tile ({visible: true, source: new ol.source.OSM ()}) Const wms = new ol.layer.Tile ({source: new ol.source.TileWMS ({url: 'http://localhost/geoserver/mapbox/wms', params: {' LAYERS': 'mapbox:city',' TILED': true}, serverType: 'geoserver' Transition: 0}) window.map = new ol.Map ({controls: ol.control.defaults ({attribution: false}). Extend ([new ol.control.ScaleLine ()]), target: 'map', layers: [base, wms], view: new ol.View ({center: options.center, zoom: options.zoom, minZoom: options.minZoom MaxZoom: options.maxZoom})}) This is the end of the introduction on "how nginx implements load balancing of multi-geoserver services". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report