Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Server in GO

A web server written in Go that supports static file serving and reverse proxying.


Architecture


Features

  • Listen on a configurable port
  • Serve static files (optional)
  • Reverse proxy to one or more backends

Run

go run .

Configuration File

Example config.conf:

listen 8080
root ./static

proxy /api localhost:9000
proxy /proxy localhost:3000

Direct Reverse Proxy Only

If you do not want to serve static files and only want to forward traffic:

listen 8080

proxy / localhost:9000

All incoming requests will be forwarded to localhost:9000.


Testing

curl http://localhost:8080/
curl http://localhost:8080/api

Project Structure

.
├── main.go
├── server.go
├── proxy.go
├── go.mod
├── utils.go
├── config.go
├── config.conf
├── static.go
├── README.md
└── static/
    └── index.html

Notes

  • Static file serving is optional
  • If root is not defined, only proxy routes are used
  • If no route matches, the server returns 404 Not Found

About

Web server from scratch written in GO supporting static file serving and reverse proxy.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages