最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

nginx實現(xiàn)多geoserver服務的負載均衡的示例代碼

 更新時間:2022年05月13日 14:23:07   作者:牛老師講GIS  
本文主要介紹了nginx實現(xiàn)多geoserver服務的負載均衡的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

概述

為了提高服務的訪問速度,減輕geoserver服務的壓力,同時避免服務節(jié)點出現(xiàn)問題而影響服務訪問的穩(wěn)定性,我們通常會通過部署多個geoserver來解決,但是部署了多個geoserver后,我們需要一個統(tǒng)一的接口提供出來供使用,nginx很好地可以這樣的需求,本文講講如何通過nginx實現(xiàn)多geoserver服務的負載均衡。

實現(xiàn)效果

實現(xiàn)

1. 多geoserver部署

為了保持geoserver的服務一致,我們先配置好一個geoserver服務,配置好之后將部署的Tomcat復制,克隆多個出來,本文為演示復制了兩個(共三個geoserver),修改Tomcat的端口,使三個端口不沖突,復制好之后分別啟動三個Tomcat。

2. nginx配置

修改nginx.conf文件,配置信息如下:

#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;
?? ??? ?}
?? ?}
}

配置好nginx后,啟動nginx。

3. 前端調用

根據上述的配置,nginx的端口為80,因此geoserver的地址為http://localhost/geoserver,在ol中的調用代碼如下:

<!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>

到此這篇關于nginx實現(xiàn)多geoserver服務的負載均衡的示例代碼的文章就介紹到這了,更多相關nginx 多geoserver負載均衡內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Nginx重定向后請求參數(shù)丟失的原因分析及解決方案

    Nginx重定向后請求參數(shù)丟失的原因分析及解決方案

    在日常開發(fā)和運維中,我們經常會遇到需要使用 Nginx 進行反向代理的場景,但在配置 proxy_pass 時,有時候可能會遇到請求參數(shù)丟失的問題,在這篇文章中,我們將會詳細探討這個問題并給出幾種解決方案,需要的朋友可以參考下
    2023-11-11
  • Nginx+Tomcat實現(xiàn)負載均衡、動靜分離的原理解析

    Nginx+Tomcat實現(xiàn)負載均衡、動靜分離的原理解析

    這篇文章主要介紹了Nginx+Tomcat實現(xiàn)負載均衡、動靜分離的原理解析,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-02-02
  • nginx配置緩存關閉的實現(xiàn)

    nginx配置緩存關閉的實現(xiàn)

    本文將介紹nginx緩存關閉,以及配置的具體步驟和示例,通過調整Nginx的配置文件,可以確保瀏覽器不會緩存網站的內容,從而提高網站的安全性和性能
    2023-10-10
  • 服務器nginx權限被拒絕解決案例

    服務器nginx權限被拒絕解決案例

    這篇文章主要為大家介紹了服務器nginx權限被拒絕解決案例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-09-09
  • kubernetes啟用PHP+Nginx網頁環(huán)境教程

    kubernetes啟用PHP+Nginx網頁環(huán)境教程

    這篇文章主要介紹了kubernetes啟用PHP+Nginx網頁環(huán)境教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-10-10
  • Nginx+uwsgi+ssl配置https的詳細步驟

    Nginx+uwsgi+ssl配置https的詳細步驟

    nginx是一個輕量級的web服務器,在處理靜態(tài)資源和高并發(fā)有優(yōu)勢,uwsgi是一個基于python的高效率的協(xié)議,處理后端和動態(tài)網頁有優(yōu)勢,我這里使用的是Ubuntu18.04版本,服務器在阿里云,感興趣的朋友跟隨小編一起看看吧
    2023-10-10
  • Nginx+Lua腳本+Redis 實現(xiàn)自動封禁訪問頻率過高IP

    Nginx+Lua腳本+Redis 實現(xiàn)自動封禁訪問頻率過高IP

    本文主要介紹了如何使用OpenResty+Lua進行動態(tài)封禁IP的解決方案,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2024-10-10
  • Nginx 實現(xiàn)灰度發(fā)布的三種方法總結

    Nginx 實現(xiàn)灰度發(fā)布的三種方法總結

    這篇文章主要介紹了Nginx 實現(xiàn)灰度發(fā)布的三種方法總結的相關資料,需要的朋友可以參考下
    2017-05-05
  • Nginx 配置過程的具體步驟

    Nginx 配置過程的具體步驟

    這篇文章主要介紹了Nginx 配置過程的詳細介紹的相關資料,希望通過本文能幫助到大家,讓大家掌握如何配置Nginx,需要的朋友可以參考下
    2017-10-10
  • Nginx 配置根據請求IP末段進行分流的方法

    Nginx 配置根據請求IP末段進行分流的方法

    這篇文章主要介紹了Nginx 配置根據請求IP末段進行分流的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-07-07

最新評論

靖州| 安新县| 九江县| 益阳市| 梁平县| 三亚市| 房产| 嫩江县| 渭南市| 九龙城区| 西充县| 平乐县| 双鸭山市| 武功县| 天气| 澄迈县| 奉节县| 菏泽市| 桦甸市| 忻州市| 宜州市| 和静县| 宁国市| 丹凤县| 海林市| 黄平县| 高青县| 安陆市| 宾阳县| 鸡泽县| 西贡区| 伊宁市| 正安县| 涞水县| 太白县| 外汇| 金门县| 礼泉县| 凤凰县| 长岭县| 冷水江市|