{"id":16307052,"url":"https://github.com/fujiwara/lamux","last_synced_at":"2026-04-03T14:07:31.839Z","repository":{"id":243264428,"uuid":"811878359","full_name":"fujiwara/lamux","owner":"fujiwara","description":"Lamux is a HTTP multiplexer for AWS Lambda Function aliases.","archived":false,"fork":false,"pushed_at":"2024-12-01T21:05:10.000Z","size":146,"stargazers_count":10,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T09:42:17.749Z","etag":null,"topics":["aws","lambda"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fujiwara.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-07T13:43:04.000Z","updated_at":"2024-12-24T11:47:14.000Z","dependencies_parsed_at":"2024-07-05T16:11:58.212Z","dependency_job_id":null,"html_url":"https://github.com/fujiwara/lamux","commit_stats":null,"previous_names":["fujiwara/lamux"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Flamux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Flamux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Flamux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fujiwara%2Flamux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fujiwara","download_url":"https://codeload.github.com/fujiwara/lamux/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238155546,"owners_count":19425732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","lambda"],"created_at":"2024-10-10T21:12:21.035Z","updated_at":"2026-04-03T14:07:31.825Z","avatar_url":"https://github.com/fujiwara.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lamux\n\n## Description\n\nLamux is a HTTP multiplexer for AWS Lambda Function aliases.\n\n## Usage\n\n```console\nUsage: lamux [flags]\n\nFlags:\n  -h, --help                              Show context-sensitive help.\n      --port=8080                         Port to listen on ($LAMUX_PORT)\n      --function-name=\"*\"                 Name of the Lambda function to proxy ($LAMUX_FUNCTION_NAME)\n      --domain-suffix=\"localdomain\"       Domain suffix to accept requests for ($LAMUX_DOMAIN_SUFFIX)\n      --upstream-timeout=30s              Timeout for upstream requests ($LAMUX_UPSTREAM_TIMEOUT)\n      --[no-]error-details                Include detailed errors in the response ($LAMUX_ERROR_DETAILS)\n      --log-level=\"INFO\"                  Log level (DEBUG, INFO, WARN, ERROR) ($LAMUX_LOG_LEVEL)\n      --version                           Show version information\n      --trace-insecure                    Disable TLS for Otel trace endpoint ($OTEL_EXPORTER_OTLP_INSECURE)\n      --trace-protocol=\"http/protobuf\"    Otel trace protocol ($OTEL_EXPORTER_OTLP_PROTOCOL)\n      --trace-headers=KEY=VALUE;...       Additional headers for Otel trace endpoint (key1=value1;key2=value2)\n                                          ($OTEL_EXPORTER_OTLP_HEADERS)\n      --trace-service=\"lamux\"             Service name for Otel trace ($OTEL_SERVICE_NAME)\n      --trace-batch                       Enable batcher for Otel trace ($OTEL_EXPORTER_OTLP_BATCH)\n\ntraceOutput\n  --trace-stdout             Enable stdout exporter for Otel trace ($OTEL_EXPORTER_STDOUT)\n  --trace-endpoint=STRING    Otel trace endpoint (e.g. localhost:4318) ($OTEL_EXPORTER_OTLP_ENDPOINT)\n```\n\nLamux runs an HTTP server that listens on a specified port and forwards requests to a specified Lambda function aliases. The Lambda function alias is identified by its name, and the domain suffix is used to determine which requests should be forwarded to it.\n\nFor example, if you run `lamux` with `--function-name=example` and `--domain-suffix=example.com`, it will forward requests to `foo.example.com` to the Lambda function aliased `example:foo`.\n\nThe forwarded Lambda functions should process Function URLs payload, but these functions do not need Function URLs settings.\n\n| Request URL | Lambda Function | Alias |\n|-------------|-----------------|-------|\n| `http://foo.example.com/` | `example` | `foo` |\n| `http://bar.example.com/` | `example` | `bar` |\n\n#### Limitations\n\nLambda alias names allow alphanumeric characters, hyphens, and underscores, but domain names do not allow underscores. And more, lamux uses `-` as a delimiter between the alias and the function name.\n\n- alias name pattern: `^[a-zA-Z0-9]+$` (`-` and `_` are not allowed)\n- function name allows: `^[a-zA-Z0-9-]+$` (`-` is allowed, `_` is not allowed)\n\n### Route to multiple Lambda functions\n\nYou can route requests to any Lambda function by specifying the `--function-name` set to `*`.\n\nIn this case, Lamux will forward requests to the Lambda function aliased `myalias-my-func.example.com` to the Lambda function `my-func` aliased as `myalias`.\n\n| Request URL | Lambda Function | Alias |\n|-------------|-----------------|-------|\n| `http://foo-bar.example.com/` | `bar` | `foo` |\n| `http://foo-baz.example.com/` | `baz` | `foo` |\n| `http://bar-baz.example.com/` | `baz` | `bar` |\n\n### Working with CloudFront and Lambda FunctionURLs\n\nLamux can work as a Lambda FunctionURLs. But in this case, Lamux cannot use the `Host` header because the Lambda function should be accessed via FunctionURLs (e.g., `***.lambda-url.us-east-1.on.aws`). So, Lamux uses the `X-Forwarded-Host` header to determine which requests should be forwarded to the Lambda function.\n\nYou may use CloudFront to forward requests to Lamux running on FunctionURLs. In this case, you should set the `X-Forwarded-Host` header to the original `Host` header value by Cloud Front Functions(CFF).\n\n```js\n// CloudFront Function for setting X-Forwarded-Host header in viewer request\nasync function handler(event) {\n  const request = event.request;\n  request.headers['x-forwarded-host'] = { value: request.headers['host'].value };\n  return request;\n}\n```\n\n### Working as a Lambda extension\n\nLamux can work as a Lambda extension. In this case, Lamux works the same as the local server mode, but it can be registered as a Lambda extension.\n\nThis mode is useful for calling other Lambda functions from the Lambda function running on a VPC without the NAT Gateway. Your Lambda handlers can invoke other Lambda functions by HTTP request to the Lamux extension.\n\nTo deploy Lamux as a Lambda extension, you need to create a Lambda layer that contains a `lamux` binary in the `extensions/` directory.\n\n```console\n$ mkdir extensions\n$ cp /path/to/lamux extensions/lamux\n$ zip -r layer.zip extensions\n$ aws lambda publish-layer-version \\\n\t\t--layer-name lamux \\\n\t\t--zip-file fileb://layer.zip \\\n\t\t--compatible-runtimes provided.al2023 provided.al2\n```\n\n## Installation\n\n[Download the latest release](https://github.com/fujiwara/lamux/releases)\n\nThe `lamux` binary is a standalone executable. You can run it on your local machine or deploy it to AWS Lambda `bootstrap` for custom runtimes (provided.al2023 or provided.al2).\n\n## Configuration\n\nAll settings can be specified via command-line flags or environment variables.\n\n### `AWS_REGION` environment variable\n\nAWS region to use.\n\n### IAM Policy\n\nLamux must have the IAM policy, which can `lambda:InvokeFunction`.\n\n```json\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": \"lambda:InvokeFunction\",\n      \"Resource\": \"*\",\n    }\n  ]\n}\n```\n\nIf you want to restrict the functions to invoke, you must set an IAM Policy to specify the Lambda function to be invoked.\n\n```json\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Effect\": \"Allow\",\n      \"Action\": \"lambda:InvokeFunction\",\n      \"Resource\": [\n        \"arn:aws:lambda:us-east-1:123456789012:function:foo:*\",\n        \"arn:aws:lambda:us-east-1:123456789012:function:bar:*\",\n      ],\n    }\n  ]\n}\n```\n\nIf `lamux` runs on Lambda Function URLs, you should attach the appropriate execution policy to the Lambda function's role. (e.g., `AWSLambdaBasicExecutionRole` managed policy)\n\n### `--port` (`$LAMUX_PORT`)\n\nPort to listen on. Default is `8080`. This setting is ignored when `lamux` running on AWS Lambda Function URLs.\n\n### `--function-name` (`$LAMUX_FUNCTION_NAME`)\n\nName of the Lambda function to proxy. This setting is required.\n\nIf you set `--function-name` to `*`, Lamux will route requests to any Lambda function. In this case, the Lambda function and alias are determined by the hostname.\n\n### `--domain-suffix` (`$LAMUX_DOMAIN_SUFFIX`)\n\nDomain suffix to accept requests for. This setting is required.\n\n### `--upstream-timeout` (`$LAMUX_UPSTREAM_TIMEOUT`)\n\nTimeout for upstream requests. Default is `30s`.\n\nThis setting is affected by the Lambda function timeout. If the Lambda function timeout is less than the `--upstream-timeout`, it will time out before the `--upstream-timeout`.\n\n### `--error-details` (`$LAMUX_ERROR_DETAILS`)\n\nInclude detailed errors in the response. Default is `true`\n\n### `--log-level` (`$LAMUX_LOG_LEVEL`)\n\nLog level for the application. Default is `INFO`.\n\nAvailable levels: `DEBUG`, `INFO`, `WARN`, `ERROR`.\n\nFor example, setting `LAMUX_LOG_LEVEL=WARN` suppresses Info-level access logs (`handleProxy`, `response`) and only outputs Warn/Error-level logs.\n\n### OpenTelemetry tracing support\n\nLamux supports OpenTelemetry tracing.\n\nWhen either of the following environment variables is set, Lamux will enable tracing.\n- `OTEL_EXPORTER_OTLP_ENDPOINT` (e.g., `localhost:4318`)\n  - When you set this environment variable, Lamux will enable tracing and send traces to the specified endpoint.\n- `OTEL_EXPORTER_STDOUT`\n  - When you set this environment variable to `true`, Lamux will enable the stdout exporter for the trace.\n\nOther optional environment variables for tracing:\n- `OTEL_EXPORTER_OTLP_PROTOCOL` (`grpc` or `http/protobuf`, default `http/protobuf`)\n- `OTEL_EXPORTER_OTLP_INSECURE` (optional)\n- `OTEL_EXPORTER_OTLP_HEADERS` (e.g., `key1=value1;key2=value2`)\n- `OTEL_SERVICE_NAME` (default `lamux`)\n- `OTEL_EXPORTER_OTLP_BATCH` (optional, default `false`)\n  - When you set this environment variable to `true`, Lamux will enable the batcher for the trace exporter.\n  - By default, the batcher is disabled, and the exporter sends traces synchronously. This is useful for running Lamux on Lambda Function URLs or debugging.\n  - The batcher is useful for running Lamux on ECS tasks or EC2 instances (which means \"long-running processes\").\n\n## LICENSE\n\nMIT\n\n## Author\n\nFujiwara Shunichiro\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffujiwara%2Flamux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffujiwara%2Flamux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffujiwara%2Flamux/lists"}