Fix the stream socket
This commit is contained in:
parent
8c5fe95578
commit
cb6c541c91
5 changed files with 12 additions and 13 deletions
|
@ -431,7 +431,6 @@ func (n *NGINXController) DefaultEndpoint() ingress.Endpoint {
|
||||||
//
|
//
|
||||||
//nolint:gocritic // the cfg shouldn't be changed, and shouldn't be mutated by other processes while being rendered.
|
//nolint:gocritic // the cfg shouldn't be changed, and shouldn't be mutated by other processes while being rendered.
|
||||||
func (n *NGINXController) generateTemplate(cfg ngx_config.Configuration, ingressCfg ingress.Configuration) ([]byte, error) {
|
func (n *NGINXController) generateTemplate(cfg ngx_config.Configuration, ingressCfg ingress.Configuration) ([]byte, error) {
|
||||||
|
|
||||||
// NGINX cannot resize the hash tables used to store server names. For
|
// NGINX cannot resize the hash tables used to store server names. For
|
||||||
// this reason we check if the current size is correct for the host
|
// this reason we check if the current size is correct for the host
|
||||||
// names defined in the Ingress rules and adjust the value if
|
// names defined in the Ingress rules and adjust the value if
|
||||||
|
@ -715,10 +714,12 @@ func nextPowerOf2(v int) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move to the right place
|
// TODO: Move to the right place
|
||||||
type PassthroughConfig map[string]PassthrougBackend
|
type (
|
||||||
type PassthrougBackend struct {
|
PassthroughConfig map[string]PassthrougBackend
|
||||||
Endpoint string `json:"endpoint,omitempty"`
|
PassthrougBackend struct {
|
||||||
}
|
Endpoint string `json:"endpoint,omitempty"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func configurePassthroughBackends(backends []*ingress.SSLPassthroughBackend) error {
|
func configurePassthroughBackends(backends []*ingress.SSLPassthroughBackend) error {
|
||||||
configPassthrough := make(PassthroughConfig)
|
configPassthrough := make(PassthroughConfig)
|
||||||
|
@ -754,13 +755,11 @@ func configurePassthroughBackends(backends []*ingress.SSLPassthroughBackend) err
|
||||||
return fmt.Errorf("error configuring passthrough: %s %v", status, err)
|
return fmt.Errorf("error configuring passthrough: %s %v", status, err)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// configureDynamically encodes new Backends in JSON format and POSTs the
|
// configureDynamically encodes new Backends in JSON format and POSTs the
|
||||||
// payload to an internal HTTP endpoint handled by Lua.
|
// payload to an internal HTTP endpoint handled by Lua.
|
||||||
func (n *NGINXController) configureDynamically(pcfg *ingress.Configuration) error {
|
func (n *NGINXController) configureDynamically(pcfg *ingress.Configuration) error {
|
||||||
|
|
||||||
if n.cfg.EnableSSLPassthrough {
|
if n.cfg.EnableSSLPassthrough {
|
||||||
if err := configurePassthroughBackends(pcfg.PassthroughBackends); err != nil {
|
if err := configurePassthroughBackends(pcfg.PassthroughBackends); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -107,7 +107,6 @@ func NewPostStatusRequest(path, contentType string, data interface{}) (statusCod
|
||||||
|
|
||||||
// TODO: Turn port configurable
|
// TODO: Turn port configurable
|
||||||
func NewPassthroughConfigRequest(data interface{}) (status string, err error) {
|
func NewPassthroughConfigRequest(data interface{}) (status string, err error) {
|
||||||
|
|
||||||
buf, err := json.Marshal(data)
|
buf, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "NOK", err
|
return "NOK", err
|
||||||
|
@ -130,9 +129,9 @@ func NewPassthroughConfigRequest(data interface{}) (status string, err error) {
|
||||||
return "NOK", err
|
return "NOK", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(string(reply), "NOK") {
|
if strings.Contains(string(reply), "NOK") {
|
||||||
return "NOK", fmt.Errorf("fail to reconfigure dynamically")
|
return "NOK", fmt.Errorf("fail to reconfigure dynamically")
|
||||||
}
|
}
|
||||||
return "OK", nil
|
return "OK", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ RUN bash -xeu -c ' \
|
||||||
/etc/ingress-controller \
|
/etc/ingress-controller \
|
||||||
/etc/ingress-controller/ssl \
|
/etc/ingress-controller/ssl \
|
||||||
/etc/ingress-controller/auth \
|
/etc/ingress-controller/auth \
|
||||||
|
/var/run/nginx \
|
||||||
/var/log \
|
/var/log \
|
||||||
/var/log/nginx \
|
/var/log/nginx \
|
||||||
/tmp/nginx \
|
/tmp/nginx \
|
||||||
|
|
|
@ -90,7 +90,7 @@ function configureWithData(configdata, s) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const PROXYSOCKET="unix:/var/run/nginxstreamproxy.sock";
|
const PROXYSOCKET="unix:/var/run/nginx/streamproxy.sock";
|
||||||
// getBackend fetches the backend given a hostname sent via SNI
|
// getBackend fetches the backend given a hostname sent via SNI
|
||||||
function getBackend(s) {
|
function getBackend(s) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -851,7 +851,7 @@ stream {
|
||||||
# This server is here just for proxy protocol enabled passthroughs
|
# This server is here just for proxy protocol enabled passthroughs
|
||||||
server {
|
server {
|
||||||
ssl_preread on;
|
ssl_preread on;
|
||||||
listen unix:/var/run/nginxstreamproxy.sock;
|
listen unix:/var/run/nginx/streamproxy.sock;
|
||||||
js_set $proxyupstream passthrough.getProxiedBackend;
|
js_set $proxyupstream passthrough.getProxiedBackend;
|
||||||
proxy_pass $proxyupstream;
|
proxy_pass $proxyupstream;
|
||||||
proxy_protocol on;
|
proxy_protocol on;
|
||||||
|
|
Loading…
Reference in a new issue