@@ -382,9 +382,12 @@ func (c *Controller) UpdateNginxConfig(ctx context.Context, containerID string,
382382 c .Logger .Debug ("writing nginx config" , zap .String ("container" , containerID ), zap .Any ("addrs" , addrs ))
383383
384384 var nginxConf string
385- writeForwardedPort := func (port string ) {
385+ writeForwardedPort := func (port string , stickySession bool ) {
386386 if len (addrs ) > 0 {
387387 nginxConf += "upstream backend" + port + " {\n "
388+ if stickySession {
389+ nginxConf += " ip_hash;\n "
390+ }
388391 for _ , addr := range addrs {
389392 nginxConf += " server " + addr + ":" + port + ";\n "
390393 }
@@ -400,12 +403,12 @@ func (c *Controller) UpdateNginxConfig(ctx context.Context, containerID string,
400403 nginxConf += "}\n "
401404 }
402405 }
403- writeForwardedPort ("8091" )
404- writeForwardedPort ("8092" )
405- writeForwardedPort ("8093" )
406- writeForwardedPort ("8094" )
407- writeForwardedPort ("8095" )
408- writeForwardedPort ("8096" )
406+ writeForwardedPort ("8091" , true )
407+ writeForwardedPort ("8092" , false )
408+ writeForwardedPort ("8093" , false )
409+ writeForwardedPort ("8094" , false )
410+ writeForwardedPort ("8095" , false )
411+ writeForwardedPort ("8096" , false )
409412
410413 confBytes := []byte (nginxConf )
411414
0 commit comments