ini Nginx Lua静态脚本服务

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ini Nginx Lua静态脚本服务相关的知识,希望对你有一定的参考价值。

FROM ubuntu

# Shameless adoptation of https://github.com/jamescmartinez/nginx-s3-upload
MAINTAINER Valmik Roy<valmikroy@gmail.com>

# Install prerequisites for Nginx compile
RUN apt-get update && \
    apt-get install -y wget tar gcc libpcre3-dev zlib1g-dev make libssl-dev libluajit-5.1-common luajit libluajit-5.1-dev curl vim

# Download Nginx
WORKDIR /tmp
RUN /usr/bin/curl -o /etc/ssl/certs/DigiCertSHA2SecureServerCA.crt https://www.digicert.com/CACerts/DigiCertSHA2SecureServerCA.crt
RUN update-ca-certificates

RUN wget http://nginx.org/download/nginx-1.6.2.tar.gz -O nginx.tar.gz && \
    mkdir nginx && \
    tar xf nginx.tar.gz -C nginx --strip-components=1

# Download Nginx modules
RUN wget https://github.com/openresty/echo-nginx-module/archive/v0.60.tar.gz -O echo-nginx-module.tar.gz && \
    mkdir echo-nginx-module && \
    tar xf echo-nginx-module.tar.gz -C echo-nginx-module --strip-components=1
RUN wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz -O ngx_devel_kit.tar.gz && \
    mkdir ngx_devel_kit && \
    tar xf ngx_devel_kit.tar.gz -C ngx_devel_kit --strip-components=1
RUN wget https://github.com/openresty/set-misc-nginx-module/archive/v0.28.tar.gz -O set-misc-nginx-module.tar.gz && \
    mkdir set-misc-nginx-module && \
    tar xf set-misc-nginx-module.tar.gz -C set-misc-nginx-module --strip-components=1
RUN wget https://github.com/openresty/lua-nginx-module/archive/v0.9.15.tar.gz -O lua-nginx-module.tar.gz && \
    mkdir lua-nginx-module && \
    tar xf lua-nginx-module.tar.gz -C lua-nginx-module --strip-components=1

# Build Nginx
WORKDIR nginx
RUN ./configure --sbin-path=/usr/local/sbin \
                --conf-path=/etc/nginx/nginx.conf \
                --pid-path=/var/run/nginx.pid \
                --error-log-path=/var/log/nginx/error.log \
                --http-log-path=/var/log/nginx/access.log \
                --with-http_ssl_module \
                --add-module=/tmp/echo-nginx-module \
                --add-module=/tmp/ngx_devel_kit \
                --add-module=/tmp/set-misc-nginx-module \
                --add-module=/tmp/lua-nginx-module && \
    make && \
    make install

# Apply Nginx config
ADD config/nginx.conf /etc/nginx/conf.d/nginx.conf
ADD artifacts  /usr/share/nginx/script/artifacts


# Expose ports
EXPOSE 8080

# Set default command
CMD ["nginx", "-g", "daemon off;", "-c", "/etc/nginx/conf.d/nginx.conf" ]
worker_processes 1;

events {
   worker_connections 1024;
}

http {
    server {
        listen 8080;
        server_name localhost;
        root /usr/share/nginx;

        error_log /dev/stdout debug;
        access_log /dev/stdout;



        location ~* ^/script/([^/]*?)/([^/]*?)$ {


          set $jira $1;
          set $filename $2;

          if ($request_method != GET) {
            return 404;
         }


          if ($jira !~ "JIRA-.*" ) {
            echo "Invalid Jira number";
            echo $jira;
            return 404;
          }


        }


        location /health {
            return 200 'OK';
            add_header Content-Type text/plain;
        }
    }
}

以上是关于ini Nginx Lua静态脚本服务的主要内容,如果未能解决你的问题,请参考以下文章

ini Nginx Lua脚本redis基于基本用户身份验证

ini IVZ:Nginx配置使用Lua作为身份验证模块。您必须使用lua支持安装nginx。请参阅Linux发行版的“openresty”或

ini 简单的NGINX服务器块用于通过DNSimple启用SSL的静态站点

openresty+lua做接口调用权限限制

nginx lua脚本 操作文件目录或者文件的默认路径的坑

Nginx内嵌Lua脚本提高分布式缓存命中率