我正在尝试使用Lua使用Openresty的环境变量:
worker_processes auto;
events { worker_connections 1024; }
env API_USERS;
env API_ROLESTECHS;
http{
server {
set_by_lua $api_users 'return os.getenv("API_USERS")';
set_by_lua $api_rolestechs 'return os.getenv("API_ROLESTECHS")';
listen 80;
location / {
root /usr/local/openresty/nginx/html;
}
rewrite ^/users/(.*)$ $api_users:8080/$1;
rewrite ^/rolestechs/(.*)$ $api_rolestechs:1323/$1;
}
}
我基本上是在说:
以下配置工作正常,但URL(myurlusers和myurlrolestechs)是硬编码的:
worker_processes auto;
events { worker_connections 1024; }
http{
server {
listen 80;
location / {
root /usr/local/openresty/nginx/html;
}
rewrite ^/users/(.*)$ http://myurlusers:8080/$1;
rewrite ^/rolestechs/(.*)$ http://myurlrolestechs:1323/$1;
}
}
API_USERS和API_ROLESTECH是运行Openresty主机的环境变量。
我错过了什么?