Parcourir la source

Merge pull request #1 from phf/master

Some basic fixes
Mohammed Al Ashaal il y a 9 ans
Parent
commit
a740137683
2 fichiers modifiés avec 50 ajouts et 50 suppressions
  1. 25 25
      README.md
  2. 25 25
      httpsify.go

+ 25 - 25
README.md

@@ -1,39 +1,39 @@
-
 # Intro
-a transparent HTTPS terminator for letsencrypt with auto certification renewal, you may need to read more about LetsEncrypt from [here](https://letsencrypt.org/)
+A transparent HTTPS proxy with automatic certificate renewal
+using https://letsencrypt.org/
 
 # How it works ?
-httpsify is a https reverse proxy ...   
-[https request] --> httpsify --> [apache/nginx/nodejs/... etc]  
-but this isn't the point because there are many https offloaders,   
-but httpsify uses letsencrypt (https://letsencrypt.org/)   
-for automatically generating free and valid ssl certificates, as well as auto renewal of certs,   
-this web server by default uses HTTP/2 .   
-you can say that httpsify is just a http/2 & letsencrypt wrapper for any http web server with no hassle, it just works .  
+httpsify is a https reverse proxy ...
+[https request] --> httpsify --> [apache/nginx/nodejs/... etc]
+but this isn't the point because there are many https offloaders,
+but httpsify uses letsencrypt (https://letsencrypt.org/)
+for automatically generating free and valid ssl certificates, as well as auto renewal of certs,
+this web server by default uses HTTP/2 .
+you can say that httpsify is just a http/2 & letsencrypt wrapper for any http web server with no hassle, it just works .
 
 # Features
-* SSL Offloader .
-* HTTP/2 support .
-* Multi-Core support .
-* Auto-Renewal for generated certificates .
-* Blazing fast .
-* Very light .
+* SSL Offloader.
+* HTTP/2 support.
+* Multi-Core support.
+* Auto-Renewal for generated certificates.
+* Blazing fast.
+* Very light.
 * Portable and small `~ 2 MB`
-* No system requirements .
+* No system requirements.
 * No configurations required, just `httpsify --domains="domain.com,www.domain.com,sub.domain.com"`
-* Passes `X-Forwarded-*` headers, `X-Real-IP` header and `X-Remote-IP`/`X-Remote-Port` to the backend server .
+* Passes `X-Forwarded-*` headers, `X-Real-IP` header and `X-Remote-IP`/`X-Remote-Port` to the backend server.
 
 # Installation
 > Currently the only available binaries are built for `linux` `386/amd64` and you can download them from [here](https://github.com/alash3al/httpsify/releases) .  
 
-# Building from source :  
-* Make sure you have `Golang` installed .  
-* `go get github.com/alash3al/httpsify`.  
-* `go install github.com/alash3al/httpsify`.  
+# Building from source :
+* Make sure you have `Golang` installed .
+* `go get github.com/alash3al/httpsify`.
+* `go install github.com/alash3al/httpsify`.
 *  make sure that `$GOPATH/bin` in your `$PATH` .
 
 # Quick Usage
-> lets say that you have extracted/built httpsify in the current working directory .  
+> lets say that you have extracted/built httpsify in the current working directory .
 ```bash
 # this is the simplest way to run httpsify
 # this will run a httpsify instance listening on port 443 and passing the incoming requests to http://localhost
@@ -44,8 +44,8 @@ you can say that httpsify is just a http/2 & letsencrypt wrapper for any http we
 # Author
 I'm [Mohammed Al Ashaal](https://www.alash3al.xyz)
 
-# Thanks 
-I must thank the following awesome libraries 
+# Thanks
+I must thank the following awesome libraries
 
 * [github.com/xenolf/lego](https://github.com/xenolf/lego)
-* [github.com/dkumor/acmewrapper](github.com/dkumor/acmewrapper)
+* [github.com/dkumor/acmewrapper](https://github.com/dkumor/acmewrapper)

+ 25 - 25
httpsify.go

@@ -4,15 +4,15 @@
 package main
 
 import (
+	"crypto/tls"
+	"flag"
+	"github.com/dkumor/acmewrapper"
 	"io"
-	"net"
 	"log"
-	"flag"
-	"strings"
+	"net"
 	"net/http"
-	"crypto/tls"
 	"path/filepath"
-	"github.com/dkumor/acmewrapper"
+	"strings"
 )
 
 // --------------
@@ -20,19 +20,19 @@ import (
 const VERSION = "httpsify/v1"
 
 var (
-	port	*string		=	flag.String("port", "443", "the port that will serve the https requests")
-	cert	*string 	=	flag.String("cert", "./cert.pem", "the cert.pem save-path")
-	key	*string 	=	flag.String("key", "./key.pem", "the key.pem save-path")
-	domains	*string 	=	flag.String("domains", "", "a comma separated list of your site(s) domain(s)")
-	backend	*string 	=	flag.String("backend", "http://127.0.0.1:80", "the backend http server that will serve the terminated requests")
-	info 	*string 	=	flag.String("info", "yes", "whether to send information about httpsify or not ^_^")
+	port    = flag.String("port", "443", "the port that will serve the https requests")
+	cert    = flag.String("cert", "./cert.pem", "the cert.pem save-path")
+	key     = flag.String("key", "./key.pem", "the key.pem save-path")
+	domains = flag.String("domains", "", "a comma separated list of your site(s) domain(s)")
+	backend = flag.String("backend", "http://127.0.0.1:80", "the backend http server that will serve the terminated requests")
+	info    = flag.String("info", "yes", "whether to send information about httpsify or not ^_^")
 )
 
 // --------------
 
 func init() {
 	flag.Parse()
-	if ( *domains == "" ) {
+	if *domains == "" {
 		log.Fatal("err> Please enter your site(s) domain(s)")
 	}
 }
@@ -41,22 +41,22 @@ func init() {
 
 func main() {
 	acme, err := acmewrapper.New(acmewrapper.Config{
-	    Domains: strings.Split(*domains, ","),
-	    Address: ":" + *port,
-	    TLSCertFile: *cert,
-	    TLSKeyFile:  *key,
-	    RegistrationFile: filepath.Dir(*cert) + "/lets-encrypt-user.reg",
-	    PrivateKeyFile:   filepath.Dir(*cert) + "/lets-encrypt-user.pem",
-	    TOSCallback: acmewrapper.TOSAgree,
+		Domains:          strings.Split(*domains, ","),
+		Address:          ":" + *port,
+		TLSCertFile:      *cert,
+		TLSKeyFile:       *key,
+		RegistrationFile: filepath.Dir(*cert) + "/lets-encrypt-user.reg",
+		PrivateKeyFile:   filepath.Dir(*cert) + "/lets-encrypt-user.pem",
+		TOSCallback:      acmewrapper.TOSAgree,
 	})
-	if err!=nil {
-	    log.Fatal("err> "+ err.Error())
+	if err != nil {
+		log.Fatal("err> " + err.Error())
 	}
-	listener, err := tls.Listen("tcp", ":" + *port, acme.TLSConfig())
+	listener, err := tls.Listen("tcp", ":"+*port, acme.TLSConfig())
 	if err != nil {
 		log.Fatal("err> " + err.Error())
 	}
-	log.Fatal(http.Serve(listener, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request){
+	log.Fatal(http.Serve(listener, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 		defer r.Body.Close()
 		req, err := http.NewRequest(r.Method, *backend, r.Body)
 		if err != nil {
@@ -64,7 +64,7 @@ func main() {
 			return
 		}
 		for k, v := range r.Header {
-			for i := 0; i < len(v); i ++ {
+			for i := 0; i < len(v); i++ {
 				if i == 0 {
 					req.Header.Set(k, v[i])
 				} else {
@@ -89,7 +89,7 @@ func main() {
 		}
 		defer res.Body.Close()
 		for k, v := range res.Header {
-			for i := 0; i < len(v); i ++ {
+			for i := 0; i < len(v); i++ {
 				if i == 0 {
 					w.Header().Set(k, v[i])
 				} else {