All Projects → justcoding121 → Titanium Web Proxy

justcoding121 / Titanium Web Proxy

Licence: mit
A cross-platform asynchronous HTTP(S) proxy server in C#.

Projects that are alternatives of or similar to Titanium Web Proxy

Libhttpserver
C++ library for creating an embedded Rest HTTP server (and more)
Stars: ✭ 464 (-58.65%)
Mutual labels:  https, http-server
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+482.26%)
Mutual labels:  https, http-server
Http
Event-driven, streaming HTTP client and server implementation for ReactPHP.
Stars: ✭ 507 (-54.81%)
Mutual labels:  https, http-server
Kvpbase
Scalable, simple RESTful object storage platform, written in C#
Stars: ✭ 43 (-96.17%)
Mutual labels:  https, http-server
Caddy
Matthew Holt began developing Caddy in 2014 while studying computer science at Brigham Young University. (The name "Caddy" was chosen because this software helps with the tedious, mundane tasks of serving the Web, and is also a single place for multiple things to be organized together.) It soon became the first web server to use HTTPS automatically and by default, and now has hundreds of contributors and has served trillions of HTTPS requests.
Stars: ✭ 35,966 (+3105.53%)
Mutual labels:  https, http-server
Http
Host These Things Please - a basic http server for hosting a folder fast and simply
Stars: ✭ 275 (-75.49%)
Mutual labels:  https, http-server
Restinio
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use
Stars: ✭ 694 (-38.15%)
Mutual labels:  https, http-server
tipi
Tipi - the All-in-one Web Server for Ruby Apps
Stars: ✭ 214 (-80.93%)
Mutual labels:  https, http-server
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-98.4%)
Mutual labels:  https, http-server
Beetlex
high performance dotnet core socket tcp communication components, support TLS, HTTP, HTTPS, WebSocket, RPC, Redis protocols, custom protocols and 1M connections problem solution
Stars: ✭ 802 (-28.52%)
Mutual labels:  https, http-server
node-jsonrpc2
JSON-RPC 2.0 server and client library, with HTTP (with Websocket support) and TCP endpoints
Stars: ✭ 103 (-90.82%)
Mutual labels:  https, http-server
Fht2p
A cross-platform HTTP static file server developed using Rust.
Stars: ✭ 28 (-97.5%)
Mutual labels:  https, http-server
PuppyProxy
A simple HTTP proxy in C# including support for HTTP CONNECT tunneling
Stars: ✭ 37 (-96.7%)
Mutual labels:  https, http-server
Jetty.project
Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
Stars: ✭ 3,260 (+190.55%)
Mutual labels:  https, http-server
libmicrohttpd-http2
HTTP/2 support for libmicrohttpd
Stars: ✭ 21 (-98.13%)
Mutual labels:  https, http-server
Cppserver
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 528 (-52.94%)
Mutual labels:  https, http-server
Mongols
C++ high performance networking with TCP/UDP/RESP/HTTP/WebSocket protocols
Stars: ✭ 250 (-77.72%)
Mutual labels:  proxy-server, http-server
Kvantum
An intellectual (HTTP/HTTPS) web server with support for server side templating (Crush, Apache Velocity and JTwig)
Stars: ✭ 17 (-98.48%)
Mutual labels:  https, http-server
Netcoreserver
Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 799 (-28.79%)
Mutual labels:  https, http-server
Go Bootstrap
Easy way to bootstrap a web server in Go (Routing|Middleware|Https)
Stars: ✭ 27 (-97.59%)
Mutual labels:  https, http-server

Titanium Web Proxy

A lightweight HTTP(S) proxy server written in C#.

Build Status Join the chat at https://gitter.im/Titanium-Web-Proxy/Lobby

Report bugs or raise issues here. For programming help use StackOverflow with the tag Titanium-Web-Proxy.

Features

  • Multithreaded and asynchronous proxy employing server connection pooling, certificate cache, and buffer pooling
  • View, modify, redirect and block requests or responses
  • Supports mutual SSL authentication, proxy authentication & automatic upstream proxy detection
  • Supports kerberos, NTLM authentication over HTTP protocols on windows domain controlled networks
  • SOCKS4/5 Proxy support

Installation

Install by nuget

For beta releases on beta branch

Install-Package Titanium.Web.Proxy -Pre

For stable releases on stable branch

Install-Package Titanium.Web.Proxy

Supports

  • .NET Standard 2.0 or above
  • .NET Framework 4.5 or above

Note to contributors

Road map

  • Fix outstanding bugs
  • Support reading request and response body as stream #823
  • Use Dispose(false) pattern to reduce possibility of memory leaks #740
  • Stop throwing new exceptions #634
  • Support HTTP 2.0

Collaborators

The owner of this project, justcoding121, is considered to be inactive from this project due to his busy work schedule. However, we have a collaborator listed below who time and again shows up to maintain this project. Please create pull requests prioritizing bug fixes for the attention of collaborators.

Development environment

Windows

  • Visual Studio Code as IDE for .NET Core
  • Visual Studio 2019 as IDE for .NET Framework/.NET Core

Mac OS

  • Visual Studio Code as IDE for .NET Core
  • Visual Studio 2019 as IDE for Mono

Linux

  • Visual Studio Code as IDE for .NET Core
  • Mono develop as IDE for Mono

Usage

Refer the HTTP Proxy Server library in your project and look up the test project to learn usage.

Setup HTTP proxy:

var proxyServer = new ProxyServer();

// locally trust root certificate used by this proxy 
proxyServer.CertificateManager.TrustRootCertificate = true;

// optionally set the Certificate Engine
// Under Mono only BouncyCastle will be supported
//proxyServer.CertificateManager.CertificateEngine = Network.CertificateEngine.BouncyCastle;

proxyServer.BeforeRequest += OnRequest;
proxyServer.BeforeResponse += OnResponse;
proxyServer.ServerCertificateValidationCallback += OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection;


var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true)
{
    // Use self-issued generic certificate on all https requests
    // Optimizes performance by not creating a certificate for each https-enabled domain
    // Useful when certificate trust is not required by proxy clients
   //GenericCertificate = new X509Certificate2(Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "genericcert.pfx"), "password")
};

// Fired when a CONNECT request is received
explicitEndPoint.BeforeTunnelConnect += OnBeforeTunnelConnect;

// An explicit endpoint is where the client knows about the existence of a proxy
// So client sends request in a proxy friendly manner
proxyServer.AddEndPoint(explicitEndPoint);
proxyServer.Start();

// Transparent endpoint is useful for reverse proxy (client is not aware of the existence of proxy)
// A transparent endpoint usually requires a network router port forwarding HTTP(S) packets or DNS
// to send data to this endPoint
var transparentEndPoint = new TransparentProxyEndPoint(IPAddress.Any, 8001, true)
{
    // Generic Certificate hostname to use
    // when SNI is disabled by client
    GenericCertificateName = "google.com"
};

proxyServer.AddEndPoint(transparentEndPoint);

//proxyServer.UpStreamHttpProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };
//proxyServer.UpStreamHttpsProxy = new ExternalProxy() { HostName = "localhost", Port = 8888 };

foreach (var endPoint in proxyServer.ProxyEndPoints)
Console.WriteLine("Listening on '{0}' endpoint at Ip {1} and port: {2} ",
    endPoint.GetType().Name, endPoint.IpAddress, endPoint.Port);

// Only explicit proxies can be set as system proxy!
proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);

// wait here (You can use something else as a wait function, I am using this as a demo)
Console.Read();

// Unsubscribe & Quit
explicitEndPoint.BeforeTunnelConnect -= OnBeforeTunnelConnect;
proxyServer.BeforeRequest -= OnRequest;
proxyServer.BeforeResponse -= OnResponse;
proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection;

proxyServer.Stop();
    

Sample request and response event handlers

private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{
    string hostname = e.HttpClient.Request.RequestUri.Host;

    if (hostname.Contains("dropbox.com"))
    {
         // Exclude Https addresses you don't want to proxy
         // Useful for clients that use certificate pinning
         // for example dropbox.com
         e.DecryptSsl = false;
    }
}

public async Task OnRequest(object sender, SessionEventArgs e)
{
    Console.WriteLine(e.HttpClient.Request.Url);

    // read request headers
    var requestHeaders = e.HttpClient.Request.RequestHeaders;

    var method = e.HttpClient.Request.Method.ToUpper();
    if ((method == "POST" || method == "PUT" || method == "PATCH"))
    {
        // Get/Set request body bytes
        byte[] bodyBytes = await e.GetRequestBody();
        e.SetRequestBody(bodyBytes);

        // Get/Set request body as string
        string bodyString = await e.GetRequestBodyAsString();
        e.SetRequestBodyString(bodyString);
    
        // store request 
        // so that you can find it from response handler 
        e.UserData = e.HttpClient.Request;
    }

    // To cancel a request with a custom HTML content
    // Filter URL
    if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("google.com"))
    {
        e.Ok("<!DOCTYPE html>" +
            "<html><body><h1>" +
            "Website Blocked" +
            "</h1>" +
            "<p>Blocked by titanium web proxy.</p>" +
            "</body>" +
            "</html>");
    }

    // Redirect example
    if (e.HttpClient.Request.RequestUri.AbsoluteUri.Contains("wikipedia.org"))
    {
        e.Redirect("https://www.paypal.com");
    }
}

// Modify response
public async Task OnResponse(object sender, SessionEventArgs e)
{
    // read response headers
    var responseHeaders = e.HttpClient.Response.ResponseHeaders;

    //if (!e.ProxySession.Request.Host.Equals("medeczane.sgk.gov.tr")) return;
    if (e.HttpClient.Request.Method == "GET" || e.HttpClient.Request.Method == "POST")
    {
        if (e.HttpClient.Response.ResponseStatusCode == "200")
        {
            if (e.HttpClient.Response.ContentType != null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
            {
                byte[] bodyBytes = await e.GetResponseBody();
                e.SetResponseBody(bodyBytes);

                string body = await e.GetResponseBodyAsString();
                e.SetResponseBodyString(body);
            }
        }
    }
    
    if (e.UserData != null)
    {
        // access request from UserData property where we stored it in RequestHandler
        var request = (Request)e.UserData;
    }
}

// Allows overriding default certificate validation logic
public Task OnCertificateValidation(object sender, CertificateValidationEventArgs e)
{
    // set IsValid to true/false based on Certificate Errors
    if (e.SslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
        e.IsValid = true;

    return Task.CompletedTask;
}

// Allows overriding default client certificate selection logic during mutual authentication
public Task OnCertificateSelection(object sender, CertificateSelectionEventArgs e)
{
    // set e.clientCertificate to override
    return Task.CompletedTask;
}

Console example application screenshot

alt tag

GUI example application screenshot

alt tag

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].