Page MenuHomeSoftware Heritage

varnish: Correctly handle the vhost when the port number is included
ClosedPublic

Authored by vsellier on Dec 11 2020, 11:42 AM.

Details

Summary

If a vhost is received with :<port>, it was not handled by the regexps
managing the backend selection and forwarded to the default backend.

Related to T2877

Test Plan

octocatalog-diff

  • moma:
diff origin/production/moma.softwareheritage.org current/moma.softwareheritage.org
*******************************************
  File[/etc/varnish/includes/50_vhost_archive.softwareheritage.org.vcl] =>
   parameters =>
     content =>
      @@ -7,8 +7,8 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)base\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)base\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -24,8 +24,8 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)base\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)base\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  File[/etc/varnish/includes/50_vhost_deposit.softwareheritage.org.vcl] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)deposit\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)deposit\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Profile::Varnish::Vcl_include[vhost_archive.softwareheritage.org] =>
   parameters =>
     content =>
      @@ -7,8 +7,8 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)base\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)base\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -24,8 +24,8 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)base\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)base\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Profile::Varnish::Vcl_include[vhost_deposit.softwareheritage.org] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)deposit\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)deposit\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Varnish::Vcl[/etc/varnish/includes/50_vhost_archive.softwareheritage.org.vcl] =>
   parameters =>
     content =>
      @@ -7,8 +7,8 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)base\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)base\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -24,8 +24,8 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)base\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)archive\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)base\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp0\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)archive\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Varnish::Vcl[/etc/varnish/includes/50_vhost_deposit.softwareheritage.org.vcl] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)deposit\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org$" ||
      -        req.http.host ~ "^(?i)deposit\.softwareheritage\.org$"
      +        req.http.host ~ "^(?i)deposit\.internal\.softwareheritage\.org(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.softwareheritage\.org(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
*** End octocatalog-diff on moma.softwareheritage.org
  • rp0.staging:
diff origin/production/rp0.internal.staging.swh.network current/rp0.internal.staging.swh.network
*******************************************
  File[/etc/varnish/includes/50_vhost_deposit.staging.swh.network.vcl] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)deposit\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)deposit\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  File[/etc/varnish/includes/50_vhost_webapp.staging.swh.network.vcl] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)webapp\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)webapp\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Profile::Varnish::Vcl_include[vhost_deposit.staging.swh.network] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)deposit\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)deposit\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Profile::Varnish::Vcl_include[vhost_webapp.staging.swh.network] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)webapp\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)webapp\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Varnish::Vcl[/etc/varnish/includes/50_vhost_deposit.staging.swh.network.vcl] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)deposit\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)deposit\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)deposit\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)deposit\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
  Varnish::Vcl[/etc/varnish/includes/50_vhost_webapp.staging.swh.network.vcl] =>
   parameters =>
     content =>
      @@ -7,6 +7,6 @@
       sub vcl_recv {
           if (
      -        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)webapp\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) == 80) {
      @@ -22,6 +22,6 @@
       sub vcl_deliver {
           if (
      -        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network$" ||
      -        req.http.host ~ "^(?i)webapp\.staging\.swh\.network$"
      +        req.http.host ~ "^(?i)webapp\-rp\.internal\.staging\.swh\.network(:[0-9]+)?$" ||
      +        req.http.host ~ "^(?i)webapp\.staging\.swh\.network(:[0-9]+)?$"
           ) {
               if (std.port(server.ip) != 80) {
*******************************************
*** End octocatalog-diff on rp0.internal.staging.swh.network

Diff Detail

Repository
rSPSITE puppet-swh-site
Branch
staging
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 17884
Build 27630: arc lint + arc unit

Event Timeline

ardumont added a subscriber: ardumont.

Neat, once that gets deployed, no more spurious error logs to the wrong server \m/

This revision is now accepted and ready to land.Dec 11 2020, 11:46 AM