Support reverse proxy IP logging.
This commit is contained in:
@@ -4,7 +4,7 @@ WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o isc .
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -v -o isc .
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
|
||||
3
main.go
3
main.go
@@ -99,10 +99,11 @@ func customLogrusLogger(logger *logrus.Logger) gin.HandlerFunc {
|
||||
username = "Anonymous"
|
||||
}
|
||||
|
||||
logger.Infof("[GIN] %3d | %10.3fms | %15s | %15s | %-7s | %s",
|
||||
logger.Infof("[GIN] %3d | %10.3fms | %15s | %15s | %15s | %-7s | %s",
|
||||
c.Writer.Status(),
|
||||
float64(elapsed.Microseconds())/1000.0,
|
||||
c.ClientIP(),
|
||||
c.Request.Header.Get("X-Forwarded-For"),
|
||||
username,
|
||||
c.Request.Method,
|
||||
c.Request.RequestURI,
|
||||
|
||||
Reference in New Issue
Block a user