搭建基于Nginx的Cesium数据服务器


1、下载Nginx并解压到服务器。

2、修改配置文件:conf/nginx.conf。

    server {
        listen       6090;#数据端口与arcserver的6080相近
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #设置允许跨域
            add_header Access-Control-Allow-Origin * always;
            add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
            add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
            if ($request_method = 'OPTIONS') {
                return 204;
            }
            root   html;
            index  index.html index.htm;
        }

        location /data {
            #设置允许跨域
            add_header Access-Control-Allow-Origin * always;
            add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
            add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
            if ($request_method = 'OPTIONS') {              
                return 204;
            }
            alias E:/VearthData/;#磁盘的目录路径
            autoindex on; #是否开启目录浏览.生产环境为on,部署环境建议为off
        }

3、创建脚本文件,各自将文件后缀改为*.bat。

启动脚本:

start nginx
pause

停止脚本:

nginx -s stop
pause

重启脚本:

nginx -s reload
pause

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM