proxy

package module
v0.0.0-...-4c89dbd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 7 Imported by: 0

README

Reverse Proxy Library

This Go library provides a reverse proxy implementation to handle requests and modify headers for a specified target domain.

Features

  • Reverse proxy setup using net/http/httputil.
  • Automatic header modification for Www-Authenticate and Location.
  • TLS configuration to skip certificate verification (for testing purposes).

Installation

To use this library, you need to have Go installed. You can get the library by running:

go get github.com/Firstnsnd/harbor-proxy

Usage

Import the package in your Go application:

import "github.com/Firstnsnd/harbor-proxy"

Create a new reverse proxy and start handling requests:

package main

import (
	"github.com/Firstnsnd/harbor-proxy"
	"log"
	"net/http"
)

var domain = "your_harbor_domain"

func main() {
	reverseProxy, err := proxy.NewReverseProxy(domain)
	if err != nil {
		log.Fatalf("Error creating reverse proxy: %v", err)
	}

	http.HandleFunc("/", reverseProxy.HandleRequest)

	log.Println("Starting proxy server on :8099")
	if err := http.ListenAndServe(":8099", nil); err != nil {
		log.Fatalf("Error starting server: %v", err)
	}
}
Configuration
  • Domain: Set the domain variable in your application to the target domain you want to proxy.
  • TLS InsecureSkipVerify: Currently set to true for testing. Do not use this setting in production.

Contributing

Feel free to submit issues or pull requests if you find any bugs or have suggestions for improvements.

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ReverseProxy

type ReverseProxy struct {
	Proxy  *httputil.ReverseProxy
	Target *url.URL
}

func NewReverseProxy

func NewReverseProxy(targetDomain string) (*ReverseProxy, error)

func (*ReverseProxy) HandleRequest

func (rp *ReverseProxy) HandleRequest(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL