SNIPROXY.CONF(5)
π SNIPROXY.CONF(5) π
okay bestie, welcome to the sniproxy config file zone β this is section 5 of the manual, and it's literally the whole vibe of how you tell sniproxy what to do. pull up a chair. π
β¨ NAME β¨
sniproxy.conf β it's the configuration file for sniproxy. that's it, that's the name, she's simple and she knows it. π¦
β¨ SYNOPSIS β¨
/etc/sniproxy.conf
β¨ DESCRIPTION β¨
so /etc/sniproxy.conf is the config file for sniproxy, no cap.
- Statements get separated by either a new line or a semi-colon. both. either. slay. π«
- Lines that start with
#are comments β your little diary entries, sniproxy will not read them. - The whole config is broken down into stanzas, and those stanzas are delimited by curly braces.
- Characters may be escaped using
\. - Oh and here's a cute one: configuration directives may be shortened as long as they're unambiguous β e.g.
user daemoninstead ofusername daemon. iconic behaviour honestly. π
πΈ USERNAME πΈ
username daemon
Specify the user sniproxy will run as. When sniproxy is launched as super user, it will drop permissions down to this user. it's giving responsible. π«Ά
πΈ PIDFILE πΈ
pidfile /var/run/sniproxy.pid
Specify the path to the pid file. heads up bestie: the directory must be writeable by the user sniproxy runs as. no write permission = no pid file = big sad. π
πΈ ERROR_LOG πΈ
error_log {
syslog daemon
priority notice
}
Specify how error messages should be handled. π
- Messages can be either logged to syslog β the
syslogdirective specifies that logs should go to a given syslog facility. - Alternatively, the
filenamedirective may be specified to log to a file. - these two options are mutually exclusive β pick one, bestie, you cannot have both. π«
- The
prioritydirective indicates what severity of messages should be logged.
Accepted priorities are the standard syslog priorities, listed here in increasing verbosity:
emergencyalertcriticalerrorwarningnoticeinfodebug
πΈ ACCESS_LOG πΈ
access_log {
filename /var/log/sniproxy/access.log
}
Specify how connections should be logged. this one can be overridden in a specific listener, so you can get per-listener main character energy. β¨
Connections are logged after both the client and server sockets have been closed β like, the whole conversation has to be over first. The syslog and priority directive may be used here just like in error_log. π
πΈ RESOLVER πΈ
resolver {
nameserver 127.0.0.1
mode ipv6_first
}
Specify how DNS queries should be resolved. ngl this is only required if you're using hostnames as addresses in the config, or using wildcard backends. If you don't specify it, IPv4-only queries will be performed using the system default name servers. casual. π¦
Four modes are supported, and here they are:
ipv4_onlyβ query for anyArecords, use the firstArecord returned (followingCNAMErecords).ipv6_onlyβ query for anyAAAArecords, use the firstAAAArecord returned (followingCNAMErecords).ipv4_firstβ query for bothAandAAAArecords, wait for both queries to complete, use the firstArecord if any, otherwise use the firstAAAArecord.ipv6_firstβ query for bothAandAAAArecords, wait for both queries to complete, use the firstAAAArecord if any, otherwise use the firstArecord.
β οΈ warning bestie, this one's serious. It is strongly recommended to use a local name server. why? because a single socket is reused for all DNS queries, so the UDP port number is predictable β meaning the query is only protected from spoofed replies by the 16 bit query ID. that's the whole protection. π Additionally, since no internal DNS caching is performed, a local resolver can improve performance. so likeβ¦ local resolver. do it. π
πΈ LISTENER πΈ
listener 192.0.2.10:80 {
protocol http
reuseport yes
table http_hosts
fallback 192.0.2.100:80
bad_requests log
source 192.0.2.10
access_log {
filename /var/log/sniproxy/http_access.log
}
}
listener [::]:80 {
protocol http
ipv6_v6only yes
table http_hosts
fallback unix:/var/run/http_fallback_unix.sock
}
Define a listening address to accept new connections from clients on. π«Ά Addresses may be specified as:
- an IPv4 literal followed by a TCP port number
- an IPv6 literal followed by a TCP port number
- a bare TCP port number
- a unix socket path prefixed with
unix:
Protocol defines how the client request should be parsed to obtain the requested hostname. two protocols are supported: http and tls. π‘
Reuseport directive controls if the port is opened in SO_REUSEPORT mode, which allows one to run several sniproxy instances on the same ip:port pair. This enables us to evenly load-balance incoming connections between these instances without the use of any external load-balancing proxy. slay. π₯ Requires Linux kernel 3.9+. Setting reuseport to "yes" enables this functionality.
The ipv6_v6only directive controls if listening on the IPv6 any address '::' will accept connections to any IPv4 address as well as an IPv6 address. This is useful if the user wants different configurations for IPv4 and IPv6, or wishes to handle IPv4 traffic with another server/proxy entirely. Only applicable to IPv6 listeners, and it's ignored on other listeners. π
Table specifies the name of the table used to lookup which server to forward the connection to, based on the hostname extracted from the initial client request. If no table directive is specified, the default, unnamed, table will be used.
The fallback directive specifies a server to be used if:
- the client request can not be parsed,
- a server can not be found in the table for the hostname specified, or
- the hostname can not be resolved.
This should be an IP address and port, or a unix socket path. π
The bad_requests directive allows logging the contents of the client request if it is not parsable β super useful for debugging, fr fr. π
The source directive allows specifying a specified address to bind to before connecting to the backend server. In most cases it is better to omit this option and allow the operating system to select the outgoing address automatically. Do not include a port number in this address β doing so will limit the proxy to one simultaneous connection to each server at a time. π
The access log configuration may be overridden on each listener. β¨
πΈ TABLE πΈ
table http_hosts {
^example\.com$ 192.0.2.101
^example\.net$ 192.0.2.102
^example\.org$ 192.0.2.103 proxy_protocol
}
Tables define how to map each hostname to a backend server. πΊοΈ Each request's hostname is matched against entries in the table in order, until a match is found and that server is used.
The server address may be either:
- an IP
- an IP and port
- a unix socket path
- a hostname
- or
'*'
If no port is specified, the port of the listener which the connection was received on will be used. π
The optional proxy_protocol option will prepend a HAProxy PROXY v1 protocol header to the proxied connection, allowing supporting webservers to obtain the source and destination IP and port of the original incoming TCP connection. it's giving β¨full contextβ¨.
β¨ SEE ALSO β¨
sniproxy(8)β go read her too, bestie π
and that's the whole page!! you ate that. π β¨ written by the SNIProxy manual, dated 22 March 2015 β yeah she's vintage but she's still iconic, and we love her for it. mwah. ππ¦π
π¦ where this page comes from
- alpine 3.24: sniproxy-doc 0.7.0-r1 Β· BSD-2-Clause
- arch rolling: sniproxy 0.7.0-2 Β· BSD-2-Clause
- nixos 26.05: sniproxy 0.7.0
- ubuntu stonking: sniproxy 0.7.0-1 Β· BSD-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms