这是我参与 8 月更文挑战的第 27 天,活动详情查看: 8月更文挑战
背景:因为项目需要将arcgis server和地形数据用ngin代理发布,现将具体操作步骤做如下记录:
1、下载nginx软件
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好
官网地址nginx.org/
2、修改配置信息
conf文件夹下nginx.conf配置信息,
配置文件中以下内容:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
按需要改为如下:
upstream arcgis{
server http://192.168.1.76:6080/;
}
server {
listen 16165;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
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/dem/;
root html;
#index index.html;
}
# 新加的
location /ag {
proxy_pass http://192.168.1.76:6080/;
#代理的arcgis server服务器的地址和端口号
proxy_redirect off;
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_next_upstream error timeout invalid_header http_500 http_504 http_404;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
3.放置数据
要发布静态地形切片数据可将切片文件放置于 nginx-1.17.1\html安装目录下的html文件夹中,配置如上
4、启动nginx
使dos命令,定位到nginx目录下,使用“start nginx.exe”启动nginx。
5、验证
(1)验证arcgis服务代理
以服务目录http://192.168.1.76:6080/arcgis/rest/services,nginx部署到192.168.1.214服务器为例。
(2)验证地形切片访问
http://localhost:16165/dem/layer.json
ps:使用nginx还可以配置负载均衡,可参考blog.csdn.net/warrenwyf/a…