GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cssivision/reverseproxy: a minimalist http/https proxy library for golang

BranchesTags
Open more actions menu

Latest commit

 

History

20 Commits
20 Commits

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
README.md
README.md
 
 
reverse.go
reverse.go
 
 
reverse_test.go
reverse_test.go
 
 

Repository files navigation

Introduction

A minimalist proxy library for go, inspired by net/http/httputil and add support for HTTPS using HTTP Tunnel

Support cancels an in-flight request by closing it's connection

Installation

go get github.com/cssivision/reverseproxy

Usage

A simple proxy

package main

import (
    "net/http"
    "net/url"
    "github.com/cssivision/reverseproxy"
)

func main() {
    http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        path, err := url.Parse("https://github.com")
        if err != nil {
            panic(err)
            return
        }
        proxy := reverseproxy.NewReverseProxy(path)
        proxy.ServeHTTP(w, r)
    }))
}

Use as a proxy server

To use proxy server, you should set browser to use the proxy server as an HTTP proxy.

package main

import (
    "net/http"
    "net/url"
    "github.com/cssivision/reverseproxy"
)

func main() {
    http.ListenAndServe(":8080", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        path, err := url.Parse("http://" + r.Host)
        if err != nil {
            panic(err)
            return
        }

        proxy := reverseproxy.NewReverseProxy(path)
        proxy.ServeHTTP(w, r)

        // Specific for HTTP and HTTPS
        // if r.Method == "CONNECT" {
        //     proxy.ProxyHTTPS(w, r)
        // } else {
        //     proxy.ProxyHTTP(w, r)
        // }
    }))
}

About

a minimalist http/https proxy library for golang

Topics

gohttphttpsreverseproxy

Resources

Readme
MIT license
Activity

Stars

92 stars

Watchers

4 watching

Forks

22 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.