Configuration - File Template

Please refer to the ServerConfig object properties for all configuration items: https://pkg.go.dev/github.com/gogf/gf/v2/net/ghttp#ServerConfig

Below is the configuration file template:

server:
    # Basic Configuration
    address:             ":80"                 # Local listening address. Default is ":80", multiple addresses are separated by ",". For example: "192.168.2.3:8000,10.0.3.10:8001"
    httpsAddr:           ":443"                # TLS/HTTPS configuration, also requires certificate and key configuration. Default is off. Configuration format is the same as above.
    httpsCertPath:       ""                    # Local path of the TLS/HTTPS certificate file, absolute path is recommended. Default is off
    httpsKeyPath:        ""                    # Local path of the TLS/HTTPS key file, absolute path is recommended. Default is off
    readTimeout:         "60s"                 # Request read timeout, generally not needed. Default is 60 seconds
    writeTimeout:        "0"                   # Data write timeout, generally not needed. Default is no timeout (0)
    idleTimeout:         "60s"                 # Valid only when Keep-Alive is enabled, request idle time. Default is 60 seconds
    maxHeaderBytes:      "10240"               # Request Header size limit (Byte). Default is 10KB
    keepAlive:           true                  # Whether to enable Keep-Alive. Default is true
    serverAgent:         "GoFrame HTTP Server" # Server agent information. Default is "GoFrame HTTP Server"

    # API Documentation
    openapiPath: "/api.json" # OpenAPI API document address
    swaggerPath: "/swagger"  # Built-in SwaggerUI display address

    # Static Service Configuration
    indexFiles:          ["index.html","index.htm"]   # Automatic homepage static file search. Default is ["index.html", "index.htm"]
    indexFolder:         false                        # Whether to display the list of files in the directory when accessing static file directory. Default is off, request will return 403
    serverRoot:          "/var/www"                   # Root path of static file service, automatically enables static file service when configured. Default is off
    searchPaths:         ["/home/www","/var/lib/www"] # Additional file search paths for providing static file service when the root path is not found, search in order. Default is off
    fileServerEnabled:   false                        # Total switch for static file service. Default is false

    # Cookie Configuration
    cookieMaxAge:        "365d"             # Cookie validity period. Default is 365 days
    cookiePath:          "/"                # Cookie valid path. Default is "/" meaning valid for all paths on the site
    cookieDomain:        ""                 # Cookie valid domain. Default is the domain name of the current configured Cookie

    # Sessions Configuration
    sessionMaxAge:       "24h"              # Session validity period. Default is 24 hours
    sessionIdName:       "gfsessionid"      # Key name of SessionId. Default is gfsessionid
    sessionCookieOutput: true               # Whether to return SessionId to Cookie when Session feature is enabled. Default is true
    sessionPath:         "/tmp/gsessions"   # File directory path for Session storage. Default is gsessions directory under the current system temporary directory

    # Basic Log Configuration
    # This configuration is similar to nginx, mainly for request log recording
    logPath:             ""                 # Directory path for storing log files, absolute path is recommended. Default is empty, meaning off
    logStdout:           true               # Whether to output the log to the terminal. Default is true
    errorStack:          true               # Whether to record stack information to the log when Server catches exceptions. Default is true
    errorLogEnabled:     true               # Whether to record exception log information to the log. Default is true
    errorLogPattern:     "error-{Ymd}.log"  # Exception error log file format. Default is "error-{Ymd}.log"
    accessLogEnabled:    false              # Whether to record access logs. Default is false
    accessLogPattern:    "access-{Ymd}.log" # Access log file format. Default is "access-{Ymd}.log"

    # Extended Log Configuration (Parameter log component configuration)
    # This configuration mainly affects server (ghttp module) logs, such as web service listening port, web service routes, and does not affect g.Log
    logger:
        path:                  "/var/log/"           # Log file path. Default is empty, meaning off, only output to terminal
        file:                  "{Y-m-d}.log"         # Log file format. Default is "{Y-m-d}.log"
        prefix:                ""                    # Log content output prefix. Default is empty
        level:                 "all"                 # Log output level
        timeFormat:            "2006-01-02T15:04:05" # Custom time format for log output, configured using Golang standard time format
        ctxKeys:               []                    # Custom Context variable names, automatically print Context variables to logs. Default is empty
        header:                true                  # Whether to print the log header information. Default is true
        stdout:                true                  # Whether to output the log to the terminal at the same time. Default is true
        rotateSize:            0                     # Rotate files by file size. Default is 0, meaning rotating feature is off
        rotateExpire:          0                     # Rotate files by time interval. Default is 0, meaning rotating feature is off
        rotateBackupLimit:     0                     # Clean up split files by the number of split files when splitting feature is enabled. Default is 0, meaning no backup, split and delete
        rotateBackupExpire:    0                     # Clean up split files by their validity period when splitting feature is enabled. Default is 0, meaning no backup, split and delete
        rotateBackupCompress:  0                     # Compression ratio (0-9) for rotated files. Default is 0, meaning no compression
        rotateCheckInterval:   "1h"                  # Time check interval for rotating splits, generally not needed. Default is 1 hour
        stdoutColorDisabled:   false                 # Disable color printing on the terminal. Default is on
        writerColorEnable:     false                 # Whether to include color in log files. Default is false, meaning no color

    # PProf Configuration
    pprofEnabled: false # Whether to enable PProf performance debugging feature. Default is false
    pprofPattern: ""    # Valid only when PProf is enabled, indicates the page access path of the PProf feature, effective for all domains bound to the current Server.

    # Graceful Restart Feature
    graceful:                false # Whether to enable graceful restart feature, adds a local TCP port with 10000 for inter-process communication when enabled. Default is false
    gracefulTimeout:         2     # Seconds for the parent process to exit after a graceful restart, default is 2 seconds. If the request takes more time than this value, it may cause the request to be interrupted
    gracefulShutdownTimeout: 5     # When the Server is shut down, if there are HTTP requests being executed, how many seconds the Server waits before forcing close

    # Other Configuration
    clientMaxBodySize:   810241024 # Client's maximum Body upload limit size, affects file upload size (Byte). Default is 8*1024*1024=8MB
    formParsingMemory:   1048576   # Buffer size (Byte) when parsing forms, generally not needed. Default is 1024*1024=1MB
    nameToUriType:       0         # Route generation rule when using object registration in route registration. Default is 0
    routeOverWrite:      false     # Whether to forcibly overwrite when encountering duplicate route registration. Default is false, duplicate routes will cause an error and exit at startup
    dumpRouterMap:       true      # Whether to print all route lists when the Server starts. Default is true