Comments (5)
I don't know if proxy_pass_header helps.
from lua-nginx-module.
I don't know if proxy_pass_header helps.
It works,but I want to set the header dynamically in lua code.
from lua-nginx-module.
You should do something like this:
upstream foo {
server 127.0.0.1:6666 weight=1;
}
server {
listen 8001;
set $dynamicConnectionHeader ''; # default value
location / {
rewrite_by_lua_block {
ngx.var.dynamicConnectionHeader = "Upgrade"
}
proxy_pass http://foo;
proxy_set_header Connection $dynamicConnectionHeader;
}
}
server {
listen 8002;
set $dynamicConnectionHeader 'Upgrade'; # default value
location / {
rewrite_by_lua_block {
ngx.var.dynamicConnectionHeader = ""
}
proxy_pass http://foo;
proxy_set_header Connection $dynamicConnectionHeader;
}
}
from lua-nginx-module.
You should do something like this:
upstream foo { server 127.0.0.1:6666 weight=1; } server { listen 8001; set $dynamicConnectionHeader ''; # default value location / { rewrite_by_lua_block { ngx.var.dynamicConnectionHeader = "Upgrade" } proxy_pass http://foo; proxy_set_header Connection $dynamicConnectionHeader; } } server { listen 8002; set $dynamicConnectionHeader 'Upgrade'; # default value location / { rewrite_by_lua_block { ngx.var.dynamicConnectionHeader = "" } proxy_pass http://foo; proxy_set_header Connection $dynamicConnectionHeader; } }
The request header to be set is obtained dynamically through Lua and cannot be hard-coded with proxy_set_header.
from lua-nginx-module.
The connection header will be specially processed by nginx proxy (the default header value is "close"). You must use proxy_set_header to set the value of the connection header. You can use Lua to set other headers normally.
from lua-nginx-module.
Related Issues (20)
- Question on memory handling in shared_dict HOT 5
- conditional shm get, eagain HOT 3
- Aborting Nginx reload on condition HOT 1
- 500 Internal Server Error HOT 1
- ngx.say not work
- init_by_lua during Nginx config test HOT 3
- Using outer scope required modules inside an ngx.timer.at handler HOT 4
- when header_filter_by_lua_file run failed. HOT 1
- OpenResty keepalive connection appears to be hung HOT 6
- unexpected phase error when `ngx.send_header()` trigger `if_unmodified` 412 logic HOT 2
- nginx: [emerg] dlopen() "/etc/nginx/ngx_http_naxsi_module.so" failed (/etc/nginx/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 nginx: configuration file /etc/nginx/nginx.conf test failed
- nginx: [emerg] dlopen() "/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so" failed (/usr/local/src/nginx-1.26.1/objs/ngx_http_naxsi_module.so: undefined symbol: pcre_exec) in /etc/nginx/nginx.conf:9 HOT 2
- Nginx + LibreSSL (undefined symbol: SSL_client_hello_get0_ext) HOT 3
- Possible to support `tcpsock:receive` in `balancer_by_lua` context?
- `ngx.req.set_body_data` API does not work in `balancer_by_lua` phase HOT 1
- errlog get_logs doesnt get error logs in privileged agent and visa versa HOT 3
- Core dumps with Lua nginx module and OCSP enabled on ingress-nginx HOT 2
- attempt to redefine .. in cdef HOT 1
- New module release HOT 2
- bug: memory leak when collecting response body chunks HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-nginx-module.