


Overview
In order to improve the access speed of the service, reduce the pressure on the geoserver service, and avoid problems with service nodes that affect the stability of service access, we usually solve the problem by deploying multiple geoservers, but deploying After installing multiple geoservers, we need a unified interface for use. nginx can meet such needs very well. This article talks about how to achieve load balancing of multiple geoserver services through nginx.
Implementation effect
Implementation
1. Multiple geoserver deployment
In order to keep the geoserver service consistent, we first Configure a geoserver service. After configuring, copy the deployed Tomcat and clone multiple ones. This article copied two (three geoservers in total) for demonstration. Modify the Tomcat port so that the three ports do not conflict. After copying, respectively Start three Tomcats.
2. nginx configuration
Modify the nginx.conf file, the configuration information is as follows:
#user nobody; worker_processes 1; #error_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; # 反向代理配置 upstream server_list{ # 这个是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.html; location = /50x.html { root html; } } }
After configuring nginx, 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:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>OpenLayers map preview</title> <link rel="stylesheet" href="lib/ol/ol.css" rel="external nofollow" type="text/css"> <link rel="stylesheet" href="css/common.css" rel="external nofollow" > <script src="../ol5/ol.js" type="text/javascript"></script> </head> <body> <div id="map" class="map"></div> <script> 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 }) }); </script> </body> </html>
The above is the detailed content of How nginx implements load balancing of multiple geoserver services. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于nginx的相关知识,其中主要介绍了nginx拦截爬虫相关的,感兴趣的朋友下面一起来看一下吧,希望对大家有帮助。

高并发系统有三把利器:缓存、降级和限流;限流的目的是通过对并发访问/请求进行限速来保护系统,一旦达到限制速率则可以拒绝服务(定向到错误页)、排队等待(秒杀)、降级(返回兜底数据或默认数据);高并发系统常见的限流有:限制总并发数(数据库连接池)、限制瞬时并发数(如nginx的limit_conn模块,用来限制瞬时并发连接数)、限制时间窗口内的平均速率(nginx的limit_req模块,用来限制每秒的平均速率);另外还可以根据网络连接数、网络流量、cpu或内存负载等来限流。1.限流算法最简单粗暴的

nginx php403错误的解决办法:1、修改文件权限或开启selinux;2、修改php-fpm.conf,加入需要的文件扩展名;3、修改php.ini内容为“cgi.fix_pathinfo = 0”;4、重启php-fpm即可。

实验环境前端nginx:ip192.168.6.242,对后端的wordpress网站做反向代理实现复杂均衡后端nginx:ip192.168.6.36,192.168.6.205都部署wordpress,并使用相同的数据库1、在后端的两个wordpress上配置rsync+inotify,两服务器都开启rsync服务,并且通过inotify分别向对方同步数据下面配置192.168.6.205这台服务器vim/etc/rsyncd.confuid=nginxgid=nginxport=873ho

跨域是开发中经常会遇到的一个场景,也是面试中经常会讨论的一个问题。掌握常见的跨域解决方案及其背后的原理,不仅可以提高我们的开发效率,还能在面试中表现的更加

nginx部署react刷新404的解决办法:1、修改Nginx配置为“server {listen 80;server_name https://www.xxx.com;location / {root xxx;index index.html index.htm;...}”;2、刷新路由,按当前路径去nginx加载页面即可。

linux版本:64位centos6.4nginx版本:nginx1.8.0php版本:php5.5.28&php5.4.44注意假如php5.5是主版本已经安装在/usr/local/php目录下,那么再安装其他版本的php再指定不同安装目录即可。安装php#wgethttp://cn2.php.net/get/php-5.4.44.tar.gz/from/this/mirror#tarzxvfphp-5.4.44.tar.gz#cdphp-5.4.44#./configure--pr

nginx禁止访问php的方法:1、配置nginx,禁止解析指定目录下的指定程序;2、将“location ~^/images/.*\.(php|php5|sh|pl|py)${deny all...}”语句放置在server标签内即可。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool