https://github.com/orijtech/frontender
Setup a server frontend with HTTPS that then proxies to traffic to a backend/cluster
https://github.com/orijtech/frontender
frontend-infrastructure proxy-server
Last synced: 4 months ago
JSON representation
Setup a server frontend with HTTPS that then proxies to traffic to a backend/cluster
- Host: GitHub
- URL: https://github.com/orijtech/frontender
- Owner: orijtech
- License: apache-2.0
- Created: 2017-06-05T07:10:52.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-27T06:01:19.000Z (over 8 years ago)
- Last Synced: 2024-06-19T16:33:36.076Z (almost 2 years ago)
- Topics: frontend-infrastructure, proxy-server
- Language: Go
- Size: 49.8 KB
- Stars: 32
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# frontender

Setup a server frontend with HTTPS that then proxies to traffic to a backend/cluster.
This project is used inside orijtech to create for folks HTTPS servers that can then be
put in Docker images, or automatically uploaded to respective cloud storage systems
and passed into some container engine for a disk image.
## Examples:
* Preamble with imports:
```go
package frontender_test
import (
"io"
"log"
"os"
"github.com/orijtech/frontender"
)
```
* Plain listen as a server:
```go
func listen() {
lc, err := frontender.Listen(&frontender.Request{
Domains: []string{
"git.orijtech.com",
"repo.orijtech.com",
},
NonHTTPSRedirectURL: "https://git.orijtech.com",
ProxyAddress: "http://localhost:9845",
NoAutoWWW: true,
})
if err != nil {
log.Fatal(err)
}
defer lc.Close()
if err := lc.Wait(); err != nil {
log.Fatal(err)
}
}
```
* Generate the binary of the server for a platform
```go
func generateBinary() {
rc, err := frontender.GenerateBinary(&frontender.DeployInfo{
FrontendConfig: &frontender.Request{
Domains: []string{
"www.medisa.orijtech.com",
"medisa.orijtech.com",
"m.orijtech.com",
},
ProxyAddress: "http://192.168.1.105:9855",
},
TargetGOOS: "linux",
Environ: []string{"CGO_ENABLED=0"},
})
if err != nil {
log.Fatal(err)
}
defer rc.Close()
f, err := os.Create("theBinary")
if err != nil {
log.Fatal(err)
}
defer f.Close()
io.Copy(f, rc)
}
```
* Generate a Docker image for the server
```go
func generateDockerImage() {
imageName, err := frontender.GenerateDockerImage(&frontender.DeployInfo{
CanonicalImageNamePrefix: "frontender",
FrontendConfig: &frontender.Request{
Domains: []string{
"git.orijtech.com",
"repo.orijtech.com",
},
NonHTTPSRedirectURL: "https://git.orijtech.com",
ProxyAddress: "http://localhost:9845",
NoAutoWWW: true,
},
ImageName: "odex-auto",
})
if err != nil {
log.Fatal(err)
}
log.Printf("ImageName: %q\n", imageName)
}
```