Apache server proxy and Cache

Source: Internet
Author: User
Tags http redirect

Apache server proxy and Cache

1. Proxy

Forward Proxy:

 

Reverse Proxy:

Mod_proxy module

A key module for implementing proxy and gateway in Apache.Load mod_proxy module: Loadmodule proxy_module modules/mod_proxy.so

Command:

  • Proxyrequests command: Enables or disables Apache as a forward proxy server. <proxymatch>/<proxy> container: stores commands acting on the proxy server and controls user permissions. proxymatch supports regular expressions.
  • Allowconnect command: Specifies the connection port number. The mod_proxy_connect module must be loaded. By default, the Apache proxy uses 443 (https) and 563 (snews) for connection. Noproxy command: No proxy is used. It is only used in the LAN.
  • Proxyblock command: block some websites you want to filter.
  • Proxydomain command: Specifies a default domain and can only act on the LAN.
  • Proxyiobuffersize command: used to adjust the size of the internal buffer. The valid value must be smaller than or equal to 8192. We recommend that you use the mod_cache module for caching.
  • Proxymaxforwards command: to prevent DoS attacks, specify the maximum number of proxies allowed to forward requests.
  • Proxypass command: maps a remote server to a local server. Common parameters: Figure proxypass Parameters
  • The proxypassreverse command is used to overwrite the location, content-location, and URL in the HTTP redirect response, so as to avoid the problem that HTTP redirection bypasses reverse proxy.
  • The proxypassreversecookiedomain and proxypassreversecookiepath commands are used to rewrite the domain name and cookie respectively. They are used in the same way as proxypassreverse.
  • Proxyremote and proxyremotematch commands: Specify the remote proxy used by this proxy, where proxyremotematch can use a regular expression.
  • Proxyreceivebuffersize command: sets the buffer size for the HTTP and FTP connections of the proxy server. The System Buffer must be greater than 512 or 0.
  • Proxytimeout command: Set the timeout value when the user connects to the proxy server.
  • Proxyerroverride command: error page provided for users in reverse proxy settings.
  • Proxybadheader command: sets how mod_proxy handles invalid response headers.
  • Proxypreservehost command: transmits the host line requested by the user to the proxy server.
  • Proxyvia command: controls the use of the Via header by the Proxy Server

Example:

ProxyRequests OnProxyVia  On<Proxy>   Order deny,allow   allow from all</Proxy>ProxyPass  /jonse  http://www.jonse.comProxyPassReverse  /jonse  http://www.jonse.com

 

Other agent modules

The following five auxiliary proxy modules must be supported by the mod_proxy module:

  • Mod_proxy_ajp: provides support for Apache JServ protocal.
  • Mod_proxy_balancer: provides support for Server Load balancer.
  • Mod_proxy_connect: provides support for the http connect Method
  • Mod_proxy_ftp: Provides FTP support
  • Mod_proxy_http: Provides the proxy HTTP Request function

 

2. Cache

The cache technology can effectively reduce server load and provide access response speed. Two cache technologies are available: disk-based and memory-based. the cache module provided by Apache can cache the web connections provided by the local server and provide cache space for the reverse proxy. The cached content is cached and indexed in URL format. The mod_cache module provides global cache settings. The mod_mem_cache and mod_disk_cache modules provide memory-based and disk-based caches respectively.

Mod_cache Module

Command:

  • Cachedefaultexpire: Set the cache resource validity period. The default value is 3600 S.
  • Cachedisable: Set a directory or URL starting with a string to not be cached.
  • Cacheenable: Specifies the cache method (MEm, disk, FD) to cache the specified directory or URL.
  • Cachemaxexpire: Maximum Cache file validity period. The default value is 86400 S (24 h ).
  • Cacheignoreheader: the specified HTTP header is not cached.
  • Cacheignorenolastmod: the cache does not set the resource of lastmod in the header.
  • Cacheignorequerystring: the query string is ignored in the cache.
  • Cachelastmodifiedfactor: used to respond to the last modified resource and calculate the expiration time.
  • Cachestorenostore: The ON and OFF switches control whether to cache when no-sotre is included in cache-control.
  • Cachestoreprivate: The ON and OFF switches control whether the cache is cached when the cache-control contains pricate.

Mod_mem_cache Module

Memory-based Cache example:

Command:

  • Mcachemaxobjectcount: used to set the maximum number of cached objects.
  • Mcachemaxobjecsize: set the maximum file size that can be cached.
  • Mcacheminobjecsize: set the minimum file size that can be cached.
  • Mcacheremovalalgorithm: Specifies the algorithm (LRU or gdsf) used to remove a document from the cache ).
  • Mcachesize: used to set the maximum amount of memory used by the cache.

Mod_disk_cache Module

Disk-based Cache example:

 

Mod_file_cache Module

Supports file caching. For example:

Mmapfile/srv/wwww/index.html -- ing content in the index.html file to the memory to provide access efficiency
Cachefile/srv/wwww/index.html -- it is of the mmapfile type and does not work as well as mmapfile, but consumes less memory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.