π¦ Rama (γ©γ) is a modular proxy framework for the π¦ Rust language to move and transform your network packets. The reasons behind the creation of rama can be read in the "Why Rama" chapter.
Rama is async-first using Tokio as its only Async Runtime.
Please refer to the examples found in the /examples
dir
to get inspired on how you can use it for your purposes.
The primary focus of Rama is to aid you in your development of proxies:
- π¦ Reverse proxies;
- π TLS Termination proxies;
- π HTTP(S) proxies;
- 𧦠SOCKS5 proxies (will be implemented in
v0.3
); - π MITM proxies;
- π΅οΈββοΈ Distortion proxies.
The Distortion proxies support
comes with User-Agent (UA) emulation capabilities. The emulations are made possible by patterns
and data extracted using rama-fp
. The service is publicly exposed at
https://fp.ramaproxy.org, made possible by our sponsor host https://fly.io/.
BrowserStack sponsors Rama by providing automated cross-platform browser testing on real devices, which uses the public fingerprinting service to aid in automated fingerprint collection on both the Http and Tls layers. By design we do not consider Tcp and Udp fingerprinting.
- Learn more by reading the Rama book at https://ramaproxy.org/book;
- or checkout the framework Rust docs at https://docs.rs/rama;
- edge docs (for main branch) can be found at https://ramaproxy.org/docs/rama.
There is no crates.io release of rama yet.
If you already want to start using rama already your can do so by referring to it in your Cargo.toml
as follows:
rama = { git = "https://github.com/plabayo/rama" }
π Rama's full documentation, references and background material can be found in the form of the "rama book" at https://ramaproxy.org/book.
π¬ Come join us at Discord on the #rama
public channel. To ask questions, discuss ideas and ask how rama may be useful for you.
- /examples/tls_termination.rs: Spawns a mini handmade http server, as well as a TLS termination proxy, forwarding the plain text stream to the first.
- /examples/tls_termination.rs: Spawns a mini handmade http server, as well as a TLS termination proxy, forwarding the plain text stream to the first.
- /examples/mtls_tunnel_and_service.rs: Example of how to do mTls (manual Tls, where the client also needs a certificate) using rama, as well as how one might use this concept to provide a tunnel service build with these concepts;
- /examples/http_connect_proxy.rs: Spawns a minimal http proxy which accepts http/1.1 and h2 connections alike, and proxies them to the target host.
Developing proxies are the primary focus of Rama (γ©γ). It can however also be used to develop web services to serve web pages, Http API's and static content. This comes with many of the same benefits that you get when developing proxies using Rama:
- Use Async Method Traits;
- Reuse modular Tower-like middleware using extensions as well as strongly typed state;
- Have the ability to be in full control of your web stack from Transport Layer (Tcp, Udp), through Tls and Http;
- If all you care about is the Http layer then that is fine to.
- Be able to trust that your incoming Application Http data has not been modified (e.g. Http header casing and order is preserved);
- Easily develop your service at a Request layer and High level functions alike, choices are yours and can be combined.
Examples of the kind of web services you might build with rama in function of your proxy service:
- a k8s health service (/examples/http_k8s_health.rs);
- a metric exposure service;
- a minimal api service (e.g. to expose device profiles or certificates);
- a graphical interface / control panel;
π Learn more about developing web services in the Rama book: https://ramaproxy.org/book/web_servers.html.
Here are some low level web service examples without fancy features:
- /examples/http_listener_hello.rs: is the most basic example on how to provide
a root service with no needs for endpoints or anything else (e.g. good enough for some use cases related
to health services or metrics exposures);
- /examples/http_health_check.rs is an even more minimal example of a health check service returning a 200 OK for any incoming request.
- /examples/http_service_hello.rs: is an example similar to the previous example but shows how you can also operate on the underlying transport (TCP) layer, prior to passing it to your http service;
There's also a premade webservice that can be used as the health service for your proxy k8s workloads:
- /examples/http_k8s_health.rs: built-in web service that can be used as a k8s health service for proxies deploying as a k8s deployment;
The following are examples that use the high level concepts of Request/State extractors and IntoResponse converters,
that you'll recognise from axum
, just as available for rama
services:
- /examples/http_key_value_store.rs:
a web service example showcasing how one might do a key value store web service using
Rama
; - /examples/http_web_service_dir_and_api.rs: a web service example showcasing how one can make a web service to serve a website which includes an XHR API;
For a production-like example of a web service you can also read the rama-fp
source code.
This is the webservice behind the Rama fingerprinting service, which is used by the maintainers of π¦ Rama (γ©γ) to generate
the UA emulation data for the Http and TLS layers. It is not meant to fingerprint humans or users. Instead it is meant to help
automated processes look like a human.
This example showcases how you can make use of the
match_service
macro to create aBox
-free service router. Another example of this approach can be seen in the http_service_match.rs example.
In The rama book you can read and learn that a big pilar of Rama's architecture is build around the Service concept. A Service
takes as input a user-defined State
(e.g. containing your database Pool) and a Request
, and uses it to serve either a Response
or Error
. Such a Service
can produce the response "directly" (also called βοΈ Leaf services) or instead pass the request and state to an inner Service
which it wraps around (so called π Middlwares).
It's a powerful concept, originally introduced to Rust by the Tower ecosystem and allows you build complex stacks specialised to your needs in a modular and easy manner. Even cooler is that this works for both clients and servers alike.
Rama provides an an HttpClient
which sends your Http Request
over the network and returns the Response
if it receives and read one or an Error
otherwise. Combined with the many Layers (middleware) that Rama
provides and perhaps also some developed by you it is possible to create a powerful Http client suited to your needs.
As a π cherry on the cake you can import the HttpClientExt
trait in your Rust module to be able to use your Http Client Service
stack using a high level API to build and send requests with ease.
The full example can be found at /examples/http_high_level_client.rs.
use rama::http::client::HttpClientExt;
let client = ServiceBuilder::new()
.layer(TraceLayer::new_for_http())
.layer(DecompressionLayer::new())
.layer(
AddAuthorizationLayer::basic("john", "123")
.as_sensitive(true)
.if_not_present(),
)
.layer(RetryLayer::new(
ManagedPolicy::default().with_backoff(ExponentialBackoff::default()),
))
.service(HttpClient::new());
#[derive(Debug, Deserialize)]
struct Info {
name: String,
example: String,
magic: u64,
}
let info: Info = client
.get("http://example.com/info")
.header("x-magic", "42")
.typed_header(Accept::json())
.send(Context::default())
.await
.unwrap()
.try_into_json()
.await
.unwrap();
This crate uses #![forbid(unsafe_code)]
to ensure everything is implemented in 100% safe Rust.
Rama (γ©γ) is developed mostly on MacOS M-Series machines and run in production on a variety of Linux systems. Windows support is not officially guaranteed, but is tested using Github Actions with success.
platform | tested | test platform |
---|---|---|
MacOS | β | M2 (developer laptop) and macos-12 Intel (GitHub Action) |
Windows | β | Windows 2022 (GitHub Action) |
Linux | β | Ubuntu 22.04 (GitHub Action) |
Please open a ticket in case you have compatibility issues for your setup/platform. Our goal is not to support all possible platformns in the world, but we do want to support as many as we reasonably can.
Rama's MSRV is 1.75
.
Using GitHub Actions we also test if rama
on that version still works on
the stable and beta versions of rust as well.
Please refer to https://github.com/plabayo/rama/milestones to know what's on the roadmap. Is there something not on the roadmap for the next version that you would really like? Please create a feature request to request it and become a sponsor if you can.
This project is dual-licensed under both the MIT license and Apache 2.0 License.
π Thanks for your help improving the project! We are so happy to have
you! We have a contributing guide to help you get involved in the
rama
project.
Contributions often come from people who already know what they want, be it a fix for a bug they encountered, or a feature that they are missing. Please do always make a ticket if one doesn't exist already.
It's possible however that you do not yet know what specifically to contribute, and yet want to help out. For that we thank you. You can take a look at the open issues, and in particular:
good first issue
: issues that are good for those new to therama
codebase;easy
: issues that are seen as easy;mentor available
: issues for which we offer mentorship;low prio
: low prio issues that have no immediate pressure to be finished quick, great in case you want to help out but can only do with limited time to spare;
In general, any issue not assigned already is free to be picked up by anyone else. Please do communicate in the ticket if you are planning to pick it up, as to avoid multiple people trying to solve the same one.
Should you want to contribure this project but you do not yet know how to program in Rust, you could start learning Rust with as goal to contribute as soon as possible to rama
by using "the Rust 101 Learning Guide" as your study companion. Glen can also be hired as a mentor or teacher to give you paid 1-on-1 lessons and other similar consultancy services. You can find his contact details at https://www.glendc.com/.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in rama
by you, shall be licensed as both MIT and Apache 2.0,
without any additional terms or conditions.
Special thanks goes to all involved in developing, maintaining and supporting the Rust programming language, the Tokio ecosystem and all other crates that we depend upon. This also includes Hyper and its ecosystem as without those projects Rama would not be. The core http module of rama is a specialised fork of hyper
and use the underlying h2
and h3
crates as dependencies.
Extra credits also go to Axum, from which ideas and code were copied as its a project very much in line with the kind of software we want Rama to be, but for a different purpose. Our hats also go off to Tower, its inventors and all the people and creatures that help make it be every day. The service concept is derived from Tower and many of our layers are a Tower fork, adapted where required or desired.
An extra big shoutout goes also to the online communities surrounding and part of these ecosystems. They are a great place to hangout and always friendly and helpful. Thanks.
Rama is completely free, open-source software which needs lots of effort and time to develop and maintain.
Support this project by becoming a sponsor. One time payments are accepted at GitHub as well as at "Buy me a Coffee".
One-time and monthly financial contributions are also possible via Paypal, should you feel more at ease with that at "Paypal Donations".
Sponsors help us continue to maintain and improve rama
, as well as other
Free and Open Source (FOSS) technology. It also helps us to create
educational content such as https://github.com/plabayo/learn-rust-101,
and other open source libraries such as https://github.com/plabayo/tower-async.
Next to the many unpaid developer hours we put in a project such as rama
,
we also have plenty of costs, such as services ranging from hosting to Docker,
but also tooling for developers and automated processing. All these costs money.
Sponsors receive perks and depending on your regular contribution it also allows you to rely on us for support and consulting.
Finally, you can also support us by shopping Plabayo <3 γ©γ
merchandise ποΈ at https://plabayo.threadless.com/.
We would like to extend our thanks to the following sponsors for funding Rama (γ©γ) development. If you are interested in becoming a sponsor, you can do so by becoming a sponsor. One time payments are accepted at GitHub as well as at "Buy me a Coffee".
If you wish to financially support us through other means you can best start a conversation with us by sending an email to [email protected].
Rama (γ©γ) is bundled with HTTP/TLS emulation data, gathered for all major platforms and browsers using real devices by BrowserStack. It does this automatically every day by using our public Fingerprinting service which is hosted together with a database on fly.io.
We are grateful to both sponsors for sponsering us these cloud resources.
π€ Enterprise support, software customisations, integrations, professional support, consultancy and training are available upon request by sending an email to [email protected].
These type of contracts are another way for you to be able to support the project and at the same time get serviced for your own needs and purposes.
Rama is licensed as both MIT and Apache 2.0, as such you are free to use and modify the source code for any purposes, including commercial goals. That said, we would appreciate it if you would consider becoming a sponsor of the project if you do end up using it for commcercial reasons.
Part of the money we receive from sponsors is used to contribute to other projects
that we depend upon. Plabayo sponsors the following organisations and individuals
building and maintaining open source software that rama
depends upon:
name | projects | |
---|---|---|
π | Tokio | (Tokio Project and Ecosystem) |
π | Ratatui | (TUI framework) |
name | projects | |
---|---|---|
π | Ulixee | (Browser Profile Data) |
π | Sean McArthur | (Hyper and Tokio) |
While there are a handful of proxies written in Rust, there are only two other Rust frameworks specifically made for proxy purposes. All other proxy codebases are single purpose code bases, some even just for learning purposes. Or are actually generic http/web libraries/frameworks that facilitate proxy features as an extra.
Cloudflare has been working on a proxy service framework, named pingora
, since a couple of years already,
and on the 28th of February of 2024 they also open sourced it.
Rama is not for everyone, but we sure hope it is right for you.
If not, consider giving pingora
a try, it might very well be the next best thing for you.
Secondly, ByteDance has an open source proxy framework written in Rust to developer forward
and reverse proxies alike, named g3proxy
.
Available at https://ramaproxy.org/book/faq.html.