Lua is a lightweight, embeddable, multi-paradigm, dynamically-typed programming languague.
Questions tagged [lua]
56 questions
8
votes
1 answer
nginx lua: os.execute waitpid() failed (10: No child processes)
So, I'm trying to execute a script on every request. I know how that sounds, this is for development environment.
I've added this to my nginx config access_by_lua_file "/opt/nginx/git-magic.lua";
git-magic.lua contains local status =…
Andrei Serdeliuc
- 905
6
votes
2 answers
Installing additional LUA modules into Redis
I'm trying to get Redis to allow EVAL (http://redis.io/commands/EVAL) to make HTTP requests.
Two modules: LuaCURL and Luasocket give this ability. The Redis source code has a directory with additional modules (such as cjson)…
user3786834
- 127
4
votes
2 answers
NGINX - OpenResty - How to reverse proxy a call to 2 different servers based based on a string?
I'm trying to configure NGINX/OpenResty to proxy SOAP calls to 2 different servers based on a string present on the SOAP request.
What I'm able to do:
I am able to proxy requests to 2 different servers based on the path the SOAP client is…
jedelvalle
- 41
4
votes
1 answer
Nginx - Empty response in error page with proxy_pass
Task: nginx config for reverse proxy to docker containers with dynamic lookup and caching.
Process workflow:
check cache. if upstream found — proxy
if not found — request it, cache and proxy
if found but cache is invalid — clear cache and run…
Terion
- 173
4
votes
1 answer
Nginx (openresty) generating random numbers
I have openresty set up on a server (nginx bundle which includes the lua module) and I'm trying to create a script which has specific odds of setting a cookie on a user's browser. My code looks like this:
location =/index.php {
set…
Mediocre Gopher
- 823
3
votes
0 answers
Docker. How to get environment variable in nginx access_by_lua_file lua script
I have nginx in a docker container, where FORWARD_LOG env variable has value 1.
In nginx.conf:
env FORWARD_LOG;
My server config:
server {
listen 80 default_server;
server_name nginx;
location / {
#resolvers
…
Morph
- 31
3
votes
1 answer
Returning HTTP status 204 for GET /generate_204 using uhttpd?
To deal with the Android captive portal detection for my specific setup, I need to return an HTTP status code 204 whenever I get a GET request for /generate_204. I currently use uhttpd as my webserver, so I'm wondering whether this is possible to do…
Markus A.
- 429
3
votes
1 answer
Passthrough captured request in nginx with lua
I'm doing something like this:
location /foo {
content_by_lua_block {
local reqType = ngx.var.request_method
if reqType == "POST"
res = ngx.location.capture("/bar")
else
res…
IAmJulianAcosta
- 343
3
votes
1 answer
Sending data to statsd does not work in some locations with content_by_lua_file
Before
Until recently I used nginx 1.4.x with zebrafishlabs/nginx-statsd as a reverse proxy for openresty (yes, I know, nginx behind nginx is stupid - keep reading please) with the following location nginx configuration:
location /track {
…
Greg Dubicki
- 1,415
- 1
- 20
- 34
3
votes
2 answers
Nginx & Lua: Hacks, optimizations & observations
Following this post on using Lua to increase nginx’s flexibility and in reducing load on the web stack I am curious to know how people are using Lua to enhance nginx’s capability.
Are there any notable hacks, optimizations & observations using…
Quintin Par
- 4,493
3
votes
0 answers
Nginx Lua module for redirecting based on proxy and access headers
In nginx I want to redirect user based on access and proxy headers. When I put it to the response header, they are shown correctly in the browser. But when using in lua to redirect with an if it does not.
For user with access app creates string…
Trouble
- 31
2
votes
2 answers
Permission denied when Nginx tries to write image file
I'm using Nginx for a Linux server and I have this folder /usr/local/openresty/nginx/webfolder/img where I want nginx to save my uploaded image files.
So, this is what I did:
1) I changed the owner of the directory to www-data user in www-data…
2
votes
1 answer
How to properly use ENV variables in Nginx config?
I want to pass the RAILS_ENV env variable to nginx and use it to set the value for the rails_env directive.
I can read the value of the variable from the environment with LUA module:
location @app {
set_by_lua $env_rails_env 'return…
Jakov Sosic
- 5,407
2
votes
0 answers
How to select the preferred file transport method?
I have a problem, as I think, with my prosody configuration: When I am sending files (for example photos) bigger than ~2 or 3 megabytes (as I established experimentally) using Converstions 2.* version (android IM app) it transfers these files using…
Bogdan Lashkov
- 141
2
votes
0 answers
Dynamic HTTP reverse proxy in nginx
Im trying to do the following where:
nginx should accept incoming requests from clients and rewrite/proxy them to dynamic upstreams as instructed by a "dynamic routing endpoint"
The dynamic routing endpoint is an external HTTP API endpoint that…
Dilip
- 139