Cómo configurar squid para que actúe como host virtual para imágenes de Docker

Cómo configurar squid para que actúe como host virtual para imágenes de Docker

Tengo un servidor que ejecuta un montón de imágenes de Docker (que básicamente solo alojan un montón de sitios web)

Todos tienen diferentes nombres de dominio y todos apuntan a la IP del servidor.

(digamos que la IP del servidor es 111.222.333.444)

(y mis dominios son www.one.com, www.two.com, www.tres.com)

Por el momento, todas las imágenes de la ventana acoplable exportan el puerto 80 al servidor en un puerto diferente:

  • www.one.com es el puerto 5080
  • www.two.com es el puerto 5180
  • www.tres.com es el puerto 5280

Entonces, si visito la URL: puerto, aparece el sitio web.

Pero quiero usar un host virtual para poder visitar el puerto 80 en cada URL y simplemente redirigir al puerto correspondiente.

Sé cómo hacer esto con Apache y probablemente podría resolverlo con nginx.

Pero he oído que para esto es realmente el calamar (además, Apache como host virtual parece muy pesado)

He instalado squid3 en mi servidor ubuntu12.04

y este es mi squid.conf hasta ahora

http_port 80 accel defaultsite=www.one.com no-vhost
cache_peer 127.0.0.1 parent 5080 0 no-query originserver name=YourAccelNameHere
acl your_site_acl dstdomain www.one.com
http_access allow your_site_acl
cache_peer_access YourAccelNameHere allow your_site_acl
cache_peer_access YourAccelNameHere deny all

De leer un tutorial que "debería" reenviar www.one.com al puerto 5080 en localhost (pero no lo es)

Realmente no tengo idea sobre los calamares y después de buscar en Google, parece que no puedo encontrar un tutorial simple para hacer lo que quiero.

¿Alguien puede indicarme un buen tutorial o, mejor aún, proporcionarme un squid.conf que haga lo que busco?

Gracias

Respuesta1

Lo respondí yo mismo

Mi solución es:

lo resolví con barniz

apt-get install varnish

Luego puse mi

/etc/default/varnish

a

START=yes
NFILES=131072
MEMLOCK=82000
DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

Luego configure mi

/etc/varnish/default.vcl

a

backend default {
    .host = "127.0.0.1";
    .port = "80";
}

backend one_website {
    .host = "127.0.0.1";
    .port = "5080";
}

backend two_website {
    .host = "127.0.0.1";
    .port = "5180";
}

## Multiple virtual host
sub vcl_recv {
 if (req.http.host ~ "^www.default.com(:[0-9]+)?$") {
    set req.backend = default;
 } else if (req.http.host ~ "^www.one.com(:[0-9]+)?$") {
    set req.backend = one_website;
 } else if (req.http.host ~ "^www.two.com(:[0-9]+)?$") {
    set req.backend = two_website;
 }
}

## Fetch
sub vcl_fetch {
        ## Remove the X-Forwarded-For header if it exists.
        remove req.http.X-Forwarded-For;

        ## insert the client IP address as X-Forwarded-For. This is the normal IP address of the user.
        set    req.http.X-Forwarded-For = req.http.rlnclientipaddr;
        ## Added security, the "w00tw00t" attacks are pretty annoying so lets block it before it reaches our webserver
        if (req.url ~ "^/w00tw00t") {
                error 403 "Not permitted";
        }
                ## Deliver the content
        return(deliver);
}

## Deliver
sub vcl_deliver {
        ## We'll be hiding some headers added by Varnish. We want to make sure people are not seeing we're using Varnish.
        ## Since we're not caching (yet), why bother telling people we use it?
        remove resp.http.X-Varnish;
        remove resp.http.Via;
        remove resp.http.Age;

        ## We'd like to hide the X-Powered-By headers. Nobody has to know we can run PHP and have version xyz of it.
        remove resp.http.X-Powered-By;
}

¡Espero que pueda ayudar a alguien más a enfrentar este problema!

información relacionada