1,前沿废话
反向代理的定义:在网络中服务器根据客户端的请求,从其关联的一组或多组后端服务器上获取资源,然后再将这些资源返回给客户端,客户端只会得知反向代理的IP地址,而不知道在代理服务器后面的服务器簇的存在。简而言之就是一个中间商。
那么明知是中间商,为什么还要让中间商赚差价?
(1)提高了内部服务器的安全。反向代理服务器可以是外部访问内部服务器的必经之路,可谓一夫当关万夫莫开。
(2)沟通内外网的桥梁。ArcGIS Enterprise部署在内网,反向代理服务器部署在内网和互联网双重网络环境,就可以实现互联网访问ArcGIS Enterprise。
1.下载nginx软件
2.软件版本
Windows Server 2019 R2 Standard
ArcGIS Enterprise 10.7
Nginx 1.17.1
3.操作步骤
3.0 安装OpenSSL 并配置环境变量(若仅http访问请跳过此步骤)
略
3.1.解压nginx 安装包
略
3.2生成ssl证书(若仅http访问请跳过此步骤)
1.在nginx的安装目录新建ssl文件夹用于放https证书。
2.命令行窗口访问ssl文件夹

3.在命令行中执行命令:openssl genrsa -des3 -out nginxgis.key1024 执行完之后输入两次密码,密码在cmd窗口中不显示。
4.在命令行中执行命令:openssl req -new -key nginxgis.key -out nginxgis.csr
5.输入证书需要的信息
6.在加载SSL支持的Nginx并使用上述私钥时除去必须的口令(可选,不选则会每次启动nginx时需要输入密码)。在命令行中执行命令:openssl rsa -in nginxgis.key.org -out nginxgis.key
7.生成crt证书,在命令行中执行命令:openssl x509 -req -days 365 -in nginxgis.csr -signkey nginxgis.key -out nginxgis.crt
8.检查ssl文件夹,此时一共应该有4个文件

3.3配置conf文件(开启https、配置证书、配置头文件、配置代理链接)
此处不考虑http与https共同存在,互相跳转等复杂情况。为了简化操作此处开启https并禁止http。若必须共存两种协议请参考以下链接配置。
http://nginx.org/en/docs/http/configuring_https_servers.html
1.打来C:\nginx\conf路径,修改nginx.conf配置文件(手滑党先备份)。

找到HTTPS server配置的那一段(即包含有listen 443 ssl配置那一段)。我们发现这段代码被注释掉了。所以,首先我们把该段代码前面的#号去掉。然后分别修改其中的ssl_certificate和ssl_certificate_key配置项为刚才所生成的nginxgis.crt和nginxgis.key这两个文件的目录。并配置server_name为www.cjl.com。
注:此处已为ArcGIS Server配置了webadaptor
2.修改nginx.conf配置文件(手滑党先备份)。
(1) 修改访问地址为你互联网url
(2) 添加https证书
(3)在location中添加以下参数
proxy_passhttps://webadaptorname.domain.com/webadaptorname;
proxy_connect_timeout 5;
proxy_read_timeout 5;
proxy_send_timeout 5;
proxy_set_headerHost $host:$server_port;
proxy_set_headerX-Real-IP $remote_addr;
proxy_set_headerX-Forwarded-Host $host;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;

3.3 修改host文件
在host文件中添加127.0.0.1 和https://www.cjl.com的映射关系
4.在ArcGIS Server Admin中添加反向代理头文件
1.打开Web浏览器以站点管理员身份登录到ArcGIS Server Administrator Directory。格式为https://server.domain.com:6443/arcgis/admin。

2.单击系统>属性>更新属性

3.在更新系统属性对话框中,插入以下负载均衡器地址( JSON格式),并点击更新数属性。
{
"WebContextURL": "https://www.cjl.com/arcgis"
}
4.重新启动站点中每台 GIS 服务器的 ArcGIS Server。在 Windows 中,这可以通过重新启动每台计算机上的ArcGIS ServerWindows 服务来实现。
5.启动nginx
1.浏览到nginx目录,输入命令行。 start nginx.ext

网友评论