我在一台windows服务器上部署了ArcGIS Server10.8.1,由于网络限制,服务器的外网只开通了8083端口,于是我准备使用nginx对其进行代理,然后外网可以访问。在windows服务器上部署了nginx在8083端口。

ArcGIS Server 禁用https

ArcGIS Server10.8.1默认启用https,而且使用的是6443端口。这就导致直接使用nginx转发会出现重定向的情况,部分情况转发失效。这里需要关闭ArcGIS Server的https访问,只使用http。

  1. 在安装ArcGIS Server的服务器浏览器访问https://localhost:6433/arcgis/admin进入ArcGIS Server的后台管理页面

  2. 输入ArcGIS Server的用户名和密码登录

  3. 点击securitysecurity

  4. 点击configconfig

  5. 点击底部的updateupdate

  6. 在Protocol中选择HTTP only,然后点击update,会自动重启服务,让服务生效Protocol

  7. 这时候通过http://localhost:6080/arcgis/admin 就可以正常进行访问了

Nginx 配置

nginx 主要配置将8083/arcgis/的请求转发到6080端口,也就是使用ArcGIS Server的占用的端口上

    server {
        listen       8083;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        location /arcgis/ { #识别以ip+/try/开始的url,进行代理
        
            proxy_pass http://localhost:6080/arcgis/; #目标地址,后面的拼接的url会自动拼接上
            #设置允许跨域
			 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;
             }
        }


        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
       }

这时候通过http://外网ip:8083/arcgis/manager就可以正常在外网访问到ArcGIS Server的管理页面了

注意

目前这个转发的方法有一些问题,就是ArcGIS Server元数据里的localhost:6080无法被替换,就导致在使用地图服务时可能会有一些问题。

更多推荐