查看安装参数命令(取出:configure arguments:)

/app/nginx/sbin/nginx -V

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl=/root/lnmp1.7/src/openssl-1.1.1d --with-openssl-opt='enable-weak-ssl-ciphers' --add-module=/root/lnmp1.7/src/headers-more-nginx-module-0.33

    #   指定允许跨域的方法,*代表所有
    more_set_headers "Access-Control-Allow-Methods: *";

    #   预检命令的缓存,如果不缓存每次会发送两次请求
    more_set_headers "Access-Control-Max-Age: 3600";
    #   带cookie请求需要加上这个字段,并设置为true
    more_set_headers "Access-Control-Allow-Credentials: true";

    #   表示允许这个域跨域调用(客户端发送请求的域名和端口) 
    #   $http_origin动态获取请求客户端请求的域   不用*的原因是带cookie的请求不支持*号
    more_set_headers "Access-Control-Allow-Origin: $http_origin";

    #   表示请求头的字段 动态获取
     more_set_headers "Access-Control-Allow-Headers: $http_access_control_request_headers";

    #   OPTIONS预检命令,预检命令通过时才发送请求
    #   检查请求的类型是不是预检命令
    if ($request_method = OPTIONS){
        return 200;
    }