Herramientas de usuario

Herramientas del sitio


linux:web:apache.config

Apache config

Ver orden en que usa los VirtualHosts
apache2ctl -S

Forzar redirects con el servername del virtualhost
UseCanonicalName On

Ver variables del servidor
<?php phpinfo(INFO_VARIABLES); ?>

Proxy Pass

URL con caracteres raros
'nocanon - Pasa la URL sin canonicalizar tal como la recibe. - Sirve para servicios REST que necesitan pasar parámetros con acentos ProxyPass /webservice balancer://api/webservice nocanon

Excluir un path del ProxyPass
ProxyPass /ciudades/aulavirtual ! ProxyPass /ciudades/ balancer://ciudades_hcluster/ciudades/ ProxyPassReverse /ciudades/ balancer://ciudades_hcluster/ciudades/

Pasar / en la url
AllowEncodedSlashes

Sobreescribir página de error
ProxyPass /error-documents ! ErrorDocument 503 /error-documents/503.html Alias /error-documents /home/stefan/repos/empfehlungsbund/public

Cache

  • Para que funcione además de habilitar el módulo hay que decomentar CacheEnable disk / en la configuración del módulo
  • El directorio de cache se puede configurar por VirtualHost (pero hay que agregarlo al htcacheclean)
  • Las urls que se cachean se pueden configurar por VirtualHost
  • Siempre que trae algo del cache aparece el header “Age: X”

Directivas que afectan al cache CacheQuickHandler Off (2.4) para que revise si la url está permitida antes de buscar en el caché UseCanonicalName On Todos los accesos al virtualhost usan la misma url cacheada

Apache 2.2

# Log
SetEnv CACHE_MISS 1
Header append CacheMISS %`CACHE_MISS`e
LogFormat "%h %l %u %t \"%r\" %>s %b MISS:%`CACHE_MISS`e %`Age`o" cache

Apache 2.4

Evitar que sirva el cache antes de procesar las directivas de url (para que no traiga del cache cosas prohibidas por location)
Sólo funciona en la configuración general del módulo
CacheQuickHandler off

# Enable the X-Cache header
CacheHeader on

# Enable the X-Cache-Detail header
CacheDetailHeader on

# Log
LogFormat "%h %l %u %t \"%r\" %>s %O %`cache-status`e %`Age`o" cache

What Can be Cached?

The full definition of which responses can be cached by an HTTP cache is defined in RFC2616 Section 13.4 Response Cacheability, and can be summed up as follows:

  • Caching must be enabled for this URL. See the CacheEnable and CacheDisable directives.
  • The response must have a HTTP status code of 200, 203, 300, 301 or 410.
  • The request must be a HTTP GET request.
  • If the response contains an “Authorization:” header, it must also contain an “s-maxage”, “must-revalidate” or “public” option in the “Cache-Control:” header, or it won't be cached.
  • If the URL included a query string (e.g. from a HTML form GET method) it will not be cached unless the response specifies an explicit expiration by including an “Expires:” header or the max-age or s-maxage directive of the “Cache-Control:” header, as per RFC2616 sections 13.9 and 13.2.1.
  • If the response has a status of 200 (OK), the response must also include at least one of the “Etag”, “Last-Modified” or the “Expires” headers, or the max-age or s-maxage directive of the “Cache-Control:” header, unless the CacheIgnoreNoLastMod directive has been used to require otherwise.
  • If the response includes the “private” option in a “Cache-Control:” header, it will not be stored unless the CacheStorePrivate has been used to require otherwise.
  • Likewise, if the response includes the “no-store” option in a “Cache-Control:” header, it will not be stored unless the CacheStoreNoStore has been used.
  • A response will not be stored if it includes a “Vary:” header containing the match-all “*”.

Problemas con proxypass en apps que no ven la IP del cliente

Si se le cierra la sesión con el mensaje de que la IP del cliente cambió y hay dos apaches de frontend que hacen reverse proxy.

mod_rpaf
It changes the remote address of the client visible to other Apache modules when two conditions are satisfied. First condition is that the remote client is actually a proxy that is defined in httpd.conf. Secondly if there is an incoming X-Forwarded-For header and the proxy is in it's list of known proxies it takes the last IP from the incoming X-Forwarded-For header and changes the remote address of the client in the request structure. In this case rpaf translates the remote address 192.168.20.50 to real client address sent in X-Forwarded-For header.

RPAFsethostname On
RPAFproxy_ips 192.168.13.31 192.168.13.32
linux/web/apache.config.txt · Última modificación: 2018/12/06 15:07 por 127.0.0.1