graygnuorg / pound

Light-weight reverse proxy, load balancer and HTTPS front-end for Web servers.
GNU General Public License v3.0
48 stars 13 forks source link

Unable to use the same backend for different virtual hosts #29

Closed abaldoni closed 4 months ago

abaldoni commented 4 months ago

Hi, I have an Apache backend which serves multiples sites on the same IP on port 80 but on different virtual hosts via the ServerName directive:

    http://app1.domain.local
    http://app2.domain.local

and so on. I'm unable to make this configuration work with pound. I defined the following backends:

  BackEnd "App1"
          Address app1.domain.local
          Port 80
  End
  BackEnd "App2"
          Address app2.domain.local
          Port 80
  End

This is not working because pound talks with the backend using its IP.

Is there any way to handle this kind of configuration?

Kind regards, A.

graygnuorg commented 4 months ago

Use the ServerName directive (available since version 4.11:

BackEnd "App1"
          Address app1.domain.local
          Port 80
          ServerName "app1.domain.local"
End

Otherwise, you can also use the SetHeader directive in Service section which encloses that backend:

Service 
   ...
   SetHeader "Host: app1.domain.local"
   Backend
      ...
   End
End
graygnuorg commented 4 months ago

A correction: ServerName is available for use in HTTPS backends only. For plain HTTP backends, you'll have to use SetHeader.

abaldoni commented 4 months ago

Thank you, it worked like a charm!