
pid tmp/nginx.pid;
worker_processes 4;
#nginx权限问题 https://github.com/smallnewer/bugs/issues/64 ps aux|grep nginx|grep -v grep
user  root;

events {
    worker_connections 4096;
}

http {
    include ./mime.types;

    client_max_body_size 10m;    #允许客户端请求的最大单文件字节数
    client_body_buffer_size 10m;  #缓冲区代理缓冲用户端请求的最大字节数

    sendfile on;
    keepalive_timeout  65;
    charset utf8;

    lua_package_path "./app/?.lua;./app/libs/?.lua;./?.lua;./lor/?.lua;./lor/lib/?.lua;;;;";
#    lua_package_path "./app/?.lua;./app/library/?.lua;./app/?/init.lua;./?.lua;/usr/local/lor/?.lua;/usr/local/lor/?/init.lua;;";
    lua_package_cpath "./app/librarys/?.so;/usr/local/lor/?.so;;";
    lua_code_cache on; # set on @production
    #LUA_SHARED_DICT

    server {
        listen 9517;
        #server_name localhost;

        # Access log with buffer, or disable it completetely if unneeded
        access_log logs/dev-www-access.log combined buffer=16k;
        # Error log
        error_log logs/dev-www-error.log;

        location /admin {
            root   ./www/;

            # try_files $uri $uri/ ;
            index  index.html index.htm;
        }
    }
    
    server {
        listen 9518;

        # Access log with buffer, or disable it completetely if unneeded
        access_log logs/dev-www-access.log combined buffer=16k;
        # Error log
        error_log logs/dev-www-error.log;

        location /api/profiler {
            proxy_pass http://127.0.0.1:9527;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;

            proxy_set_header Host $host:$server_port;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }

        location /api/ {
            proxy_pass http://127.0.0.1:9527;
        }
    }

    server {
        listen 7777;
        #server_name localhost;
        set $template_root '';

        # # 项目本身的静态文件
        # location /static/css {
        #     alias ./app/static/css;
        # }
        # location /static/img {
        #     alias ./app/static/img;
        # }
        # location /static/fonts {
        #     alias ./app/static/fonts;
        # }
        # location /static/js {
        #     alias ./app/static/js;
        # }
        

        # Access log with buffer, or disable it completetely if unneeded
        access_log logs/dev-api-access.log combined buffer=16k;
        # Error log
        error_log logs/dev-api-error.log;

        # lor runtime
        location / {
            content_by_lua_file ./app/main.lua;
        }
    }
}