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

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

2、修改配置文件

    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

猜你喜欢

转载自www.cnblogs.com/airscrat/p/12954996.html