# nginx.vh.default.conf -- docker-openresty # # This file is installed to: # `/etc/nginx/conf.d/default.conf` # # It tracks the `server` section of the upstream OpenResty's `nginx.conf`. # # This config (and any other configs in `etc/nginx/conf.d/`) is loaded by # default by the `include` directive in `/usr/local/openresty/nginx/conf/nginx.conf`. # # See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files # server { listen 80; server_name localhost; #charset koi8-r; # #access_log /var/log/nginx/host.access.log main; types { } default_type application/json; location / { proxy_pass http://127.0.0.1:2015; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; proxy_set_header X-Forwarded-Host $server_name; proxy_max_temp_file_size 0; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_cache_bypass $http_upgrade; # Remove the Connection header if the client sends it, # it could be "close" to close a keepalive connection proxy_set_header Connection ""; } # location / { # root /usr/local/openresty/nginx/html; # index index.html index.htm; # lua_need_request_body on; # content_by_lua ' # local resp = {headers=nil, body=nil} # local json_safe = require "cjson.safe" # resp.headers = ngx.req.get_headers() # local body_data = ngx.unescape_uri(ngx.var.request_body) # local b = json_safe.decode(body_data) # if not b then # resp.body = body_data # else # resp.body = b # end # resp.httpMethod = ngx.req.get_method() # resp.queryStringParameters = ngx.req.get_uri_args() # resp.path = ngx.var.uri # ngx.print( json_safe.encode(resp) ) ; # '; # } location /nginx_status { stub_status; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/local/openresty/nginx/html; } location = /time { content_by_lua_block { ngx.say( ngx.time() ) } } location = /http_time { content_by_lua_block { ngx.say( ngx.http_time(ngx.now()) ) } } location = /cookie_time { content_by_lua_block { ngx.say( ngx.cookie_time(ngx.now()) ) } } location = /utctime { content_by_lua_block { ngx.say( ngx.utctime() ) } } location = /now { content_by_lua_block { ngx.say( ngx.now() ) } } location = /ip { content_by_lua_block { ngx.say(ngx.var.remote_addr) }} location = /now_no_chunk_return { chunked_transfer_encoding off; content_by_lua_block { local buf = ngx.now() ngx.header["Content-Length"] = #tostring(buf) --ngx.header["Transfer-Encoding"] = "" ngx.print( buf ) } } location = /healthz { content_by_lua_block { ngx.say("pong") }} location = /debug/echo_request { lua_need_request_body on; content_by_lua ' local resp = {headers=nil, body=nil} local json_safe = require "cjson.safe" resp.headers = ngx.req.get_headers() local body_data = ngx.unescape_uri(ngx.var.request_body) local b = json_safe.decode(body_data) if not b then resp.body = body_data else resp.body = b end resp.httpMethod = ngx.req.get_method() resp.queryStringParameters = ngx.req.get_uri_args() resp.path = ngx.var.uri ngx.print( json_safe.encode(resp) ) ; '; } }