• openresty-nginx 线上conf分析


    今天在某业务中看到一些比较有学习意义的nginx配置,故拿出来解析一下。

    ---------------------------------------------------------------------------------------------------

    # -*- coding:utf-8 -*-

    lua_shared_dict realtime_variable 16m; //ngx_lua模块中使用共享内存
    lua_shared_dict lixian_zone_server_gim_schedule 100m; //ngx_lua模块中使用共享内存

    server {
    listen 80;
    server_name 隐藏信息;

    access_log logs/隐藏信息.access.log access_log_format;
    error_log logs/隐藏信息.error.log warn;

    default_type application/json; //默认传给浏览器json格式的响应
    charset utf-8;
    charset_types application/json; //模块在响应时能处理application/json文件

    lua_code_cache on; //开启lua代码缓存,必开,否则性能差

    set $project_lib_path 隐藏信息; //设置变量

    location ~* ^隐藏信息{
    if ($request_method = 'OPTIONS') {  //添加跨域请求,通常其他域名调用该域名时,会提前发出options的请求信息,如果域名在允许名单中,就返回204表示可以跨域。
    add_header Access-Control-Allow-Origin "$http_origin";
    add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
    add_header Access-Control-Allow-Headers "Content-Type, Authorization";
    return 204;
    }
    access_by_lua_file $project_lib_path/lua/access_check.lua; //access_by_lua在请求访问阶段处理,用于访问控制
    content_by_lua_file $project_lib_path/lua/tasks/entry.lua; //content_by_lua是内容处理器,接受请求并输出响应
    log_by_lua_file /usr/local/openresty/nginx/conf/http_status_lua/record.lua; //lua日志配置
    }

    location ~* ^隐藏信息 {

    if ($request_method = 'OPTIONS') {
    add_header Access-Control-Allow-Origin "$http_origin";
    add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
    add_header Access-Control-Allow-Headers "Content-Type, Authorization";
    return 204;
    }
    access_by_lua_file $project_lib_path/lua/access_check.lua;
    content_by_lua_file $project_lib_path/lua/tasks/entry.lua;
    log_by_lua_file /usr/local/openresty/nginx/conf/http_status_lua/record.lua;
    }

    .

    .
    .

    location ~* ^ 隐藏信息{

    if ($request_method = 'OPTIONS') {
    add_header Access-Control-Allow-Origin "$http_origin";
    add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
    add_header Access-Control-Allow-Headers "Content-Type, Authorization";
    return 204;
    }
    content_by_lua_file $project_lib_path/lua/search/entry.lua;
    }


    location ^~ 隐藏信息 {
    proxy_pass http:/隐藏信息:8908/;
    proxy_set_header Host 隐藏信息;   //转发并以某个域名取请求后端的8908
    }

    include monitor.conf;
    }

  • 相关阅读:
    editActionsForRowAtIndexPath(iOS8) tableview编辑(删除、插入、移动)
    iOS--NSNetService和NSNetServiceBrowser(Bonjour网络编程)
    Hyperledger Fabric创建通道抛错Error: got unexpected status: FORBIDDEN -- Failed to reach implicit threshold of 1 sub-policies, required 1 remaining: permission denied解决方案
    Python作业第一课
    我们都要幸福
    SSRS奇怪报错Could not update a list of fields for the quer.
    有感于审计署计算机中级培训
    python笔记——第二天
    学习python——博客记录第一天
    bzoj1027 合金
  • 原文地址:https://www.cnblogs.com/normanlin/p/13960985.html
Copyright © 2020-2023  润新知