4 Frontend system using Apache, allowing to rewrite and proxy URLs like
5 myinstance.myfrontenddomainname.com to real IP/URL of myinstance.
7 apache_frontend works using the master instance / slave instance design.
8 It means that a single main instance of Apache will be used to act as frontend
14 Apache frontend is available in 3 software types:
15 * default : The standard way to use the apache frontend configuring everything with a few given parameters
16 * custom-personal : This software type allow each slave to edit its apache configuration file
17 * custom-group : This software type use a template given as a parameter on master instance to generate apache configuration for all slaves
18 * replicate : This software type is set to replicate any kind of apache
20 About replicate frontend
21 ========================
23 Slaves of the root instance (type "replicate") are sent as a parameter to requested frontends which will process them. The only difference is that they will then return the « would-be published information » to the root instance instead of publishing it. The root instance will then do a synthesis and publish the information to its slaves. The replicate instance only use 3 type of parameters for itself and will transmit the rest to requested frontends.
24 These parameters are :
25 * "-frontend-type" : the type to deploy frontends with. (default to 2)
26 * "-frontend-quantity" : The quantity of frontends to request (default to "default")
27 * "-sla-i-foo" : where "i" is the number of the concerned frontend (between 1 and "-frontend-quantity") and "foo" a sla parameter.
29 <parameter id="-frontend-quantity">3</parameter>
30 <parameter id="-frontend-type">custom-personal</parameter>
31 <parameter id="-sla-3-computer_guid">COMP-1234</parameter>
32 will request the third frontend on COMP-1234. All frontends will be of software type "custom-personal".
34 Note: the way slaves are transformed to a parameter avoid modifying more than 3 lines in the frontend logic.
35 Important NOTE: The way you ask for slave to a replicate frontend is the same as the one you would use for the software given in "-frontend-quantity". Do not forget to use "replicate" for software type. XXXXX So far it is not possible to do a simple request on a replicate frontend if you do not know the software_guid or other sla-parameter of the master instance. In fact we do not know yet the software type of the "requested" frontends. TO BE IMPLEMENTED
37 How to deploy a frontend server
38 ===============================
40 This is to deploy an entire frontend server with a public IPv4.
41 If you want to use an already deployed frontend to make your service available
42 via ipv4, switch to the "Example" parts.
44 First, you will need to request a "master" instance of Apache Frontend with:
45 * A "domain" parameter where the frontend will be available
46 * A "public-ipv4" parameter to state which public IPv4 will be used
49 <?xml version='1.0' encoding='utf-8'?>
51 <parameter id="domain">moulefrite.org</parameter>
52 <parameter id="public-ipv4">xxx.xxx.xxx.xxx</parameter>
55 Then, it is possible to request many slave instances
56 (currently only from slapconsole, UI doesn't work yet)
57 of Apache Frontend, like::
59 software_release=apache_frontend,
60 partition_reference='frontend2',
62 partition_parameter_kw={"url":"https://[1:2:3:4]:1234/someresource"}
64 Those slave instances will be redirected to the "master" instance,
65 and you will see on the "master" instance the associated RewriteRules of
68 Finally, the slave instance will be accessible from:
69 https://someidentifier.moulefrite.org.
73 Default and custom-personal software type can handle specific ssl for one slave instance.
74 IMPORTANT: One apache can not serve more than One specific SSL VirtualHost and be compatible with obsolete browser (i.e.: IE8). See http://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI
76 #How to have custom configuration in frontend server
77 #===================================================
79 #In your instance directory, you, as sysadmin, can directly edit two
80 #configuration files that won't be overwritten by SlapOS to customize your
83 # * $PARTITION_PATH/srv/srv/apache-conf.d/apache_frontend.custom.conf
84 # * $PARTITION_PATH/srv/srv/apache-conf.d/apache_frontend.virtualhost.custom.conf
86 #The first one is included in the end of the main apache configuration file.
87 #The second one is included in the virtualhost of the main apache configuration file.
89 #SlapOS will jsut create those two files for you, then completely forget them.
91 #Note: make sure that the UNIX user of the instance has read access to those
92 #files if you edit them.
97 Master Instance Parameters
98 --------------------------
102 name of the domain to be used (example: mydomain.com). Subdomains of this
103 domain will be used for the slave instances (example:
104 instance12345.mydomain.com). It is then recommended to add a wildcard in DNS
105 for the subdomains of the chosen domain like::
106 *.mydomain.com. IN A 123.123.123.123
107 Using the IP given by the Master Instance.
108 "domain" is a mandatory Parameter.
112 Public ipv4 of the frontend (the one Apache will be indirectly listening to)
116 Port used by Apache. Optional parameter, defaults to 4443.
120 Port used by apache to serve plain http (only used to redirect to https).
121 Optional parameter, defaults to 8080.
125 Use to set IPReadLimit Parameter for antiloris.
126 Optional parameter, defaults to 10.
128 apache_custom_http (custom-group)
129 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130 Jinja template for apache virtualhost http configuration. It will be used by all slaves
132 apache_custom_https (custom-group)
133 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134 Jinja template for apache virtualhost https configuration. It will be used by all slaves
137 Slave Instance Parameters (default)
138 -----------------------------------
142 url of backend to use.
143 "url" is a mandatory parameter.
144 Example: http://mybackend.com/myresource
148 Specify if slave instance should use a squid to connect to backend.
149 Possible values: "true", "false".
150 "enable_cache" is an optional parameter. Defaults to "false".
155 Specify if slave instance will redirect to a zope backend. If specified, Apache
156 RewriteRule will use Zope's Virtual Host Daemon.
157 Possible values: "zope", "default".
158 "type" is an optional parameter. Defaults to "default".
161 domain (former custom_domain)
162 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163 Domain name to use as frontend. The frontend will be accessible from this domain.
164 "domain" is an optional parameter. Defaults to
165 [instancereference].[masterdomain].
166 Example: www.mycustomdomain.com
170 Specify if website should be accessed using https only. If so, the frontend
171 will redirect the user to https if accessed from http.
172 Possible values: "true", "false".
173 "https-only" is an optional parameter. Defaults to "false".
178 Only used if type is "zope".
180 Will append the specified path to the "VirtualHostRoot" of the zope's
183 "path" is an optional parameter, ignored if not specified.
184 Example of value: "/erp5/web_site_module/hosting/"
186 Slave Instance Parameters (custom-personal)
187 -------------------------------------------
191 Raw apache configuration in python template format (i.e. write "%%" for one "%") for the slave listening to the https port. Its content will be templatified in order to access functionalities such as cache access, ssl certificates... The list is available above.
192 NOTE: If you want to use the cache, use the apache option "ProxyPreserveHost On"
196 Raw apache configuration in python template format (i.e. write "%%" for one "%") for the slave listening to the http port. Its content will be templatified in order to access functionalities such as cache access, ssl certificates... The list is available above
197 NOTE: If you want to use the cache, use the apache option "ProxyPreserveHost On"
201 Necesarry to activate cache. url of backend to use.
202 "url" is an optional parameter.
203 Example: http://mybackend.com/myresource
207 Necesarry to activate cache. The frontend will be accessible from this domain.
208 "domain" is an optional parameter.
209 Example: www.mycustomdomain.com
213 Necesarry to activate cache.
214 "enable_cache" is an optional parameter.
216 ssl_key, ssl_crt, ssl_ca_crt, ssl_crs
217 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218 SSL certificates of the slave.
221 Functionalities for apache configuration:
222 In the slave apache configuration you can use parameters that will be replaced during instanciation. They should be entered as python templates parameters ex:" %(parameter)s"
223 * cache_access : url of the cache. Should replace backend url in configuration to use the cache
224 * error_log : path of the slave error log in order to log in a deferenciated file.
225 * error_log : path of the slave access log in order to log in a deferenciated file.
226 * ssl_key, ssl_crt, ssl_ca_crt, ssl_crs : path of the certificates given in slave instance parameters
228 Slave Instance Parameters (custom-group)
229 ----------------------------------------
233 Necesarry to activate cache. url of backend to use.
234 "url" is an optional parameter.
235 Example: http://mybackend.com/myresource
239 Domain name to use as frontend. The frontend will be accessible from this domain.
240 "domain" is an optional parameter necessary to activate cache. Defaults to
241 [instancereference].[masterdomain].
242 Example: www.mycustomdomain.com
244 The rest of the parameters are defined by templates given to the master and accessible by the slave_parameter dict in it.
250 Here are some example of how to make your SlapOS service available through
251 an already deployed frontend.
253 Simple Example (default)
254 ------------------------
256 Request slave frontend instance so that https://[1:2:3:4:5:6:7:8]:1234 will be
257 redirected and accessible from the proxy::
259 software_release=apache_frontend,
260 software_type="RootSoftwareInstance",
261 partition_reference='my frontend',
263 partition_parameter_kw={
264 "url":"https://[1:2:3:4:5:6:7:8]:1234",
269 Zope Example (default)
270 ----------------------
272 Request slave frontend instance using a Zope backend so that
273 https://[1:2:3:4:5:6:7:8]:1234 will be redirected and accessible from the
276 software_release=apache_frontend,
277 software_type="RootSoftwareInstance",
278 partition_reference='my frontend',
280 partition_parameter_kw={
281 "url":"https://[1:2:3:4:5:6:7:8]:1234",
287 Advanced example (default)
288 --------------------------
290 Request slave frontend instance using a Zope backend, with Varnish activated,
291 listening to a custom domain and redirecting to /erp5/ so that
292 https://[1:2:3:4:5:6:7:8]:1234/erp5/ will be redirected and accessible from
295 software_release=apache_frontend,
296 software_type="RootSoftwareInstance",
297 partition_reference='my frontend',
299 partition_parameter_kw={
300 "url":"https://[1:2:3:4:5:6:7:8]:1234",
301 "enable_cache":"true",
304 "domain":"mycustomdomain.com",
308 Simple Example (custom-personal)
309 --------------------------------
311 Request slave frontend instance so that https://[1:2:3:4:5:6:7:8]:1234 will be
313 software_release=apache_frontend,
314 software_type="RootSoftwareInstance",
315 partition_reference='my frontend',
317 software_type="custom-personal",
318 partition_parameter_kw={
319 "url":"https://[1:2:3:4:5:6:7:8]:1234",
321 "apache_custom_https":'
322 ServerName www.example.org
323 ServerAlias example.org
324 ServerAdmin geronimo@example.org
332 RewriteRule ^/(.*) https://[1:2:3:4:5:6:7:8]:1234/$1 [L,P]',
334 "apache_custom_http":'
335 ServerName www.example.org
336 ServerAlias www.example.org
337 ServerAlias example.org
338 ServerAdmin geronimo@example.org
345 # Remove "Secure" from cookies, as backend may be https
346 Header edit Set-Cookie "(?i)^(.+);secure$" "$1"
347 # Not using HTTPS? Ask that guy over there.
348 # Dummy redirection to https. Note: will work only if https listens
349 # on standard port (443).
350 RewriteRule ^/(.*) https://[1:2:3:4:5:6:7:8]:1234/$1 [L,P],
354 Simple Cache Example (custom-personal)
355 --------------------------------
357 Request slave frontend instance so that https://[1:2:3:4:5:6:7:8]:1234 will be
359 software_release=apache_frontend,
360 software_type="RootSoftwareInstance",
361 partition_reference='my frontend',
363 software_type="custom-personal",
364 partition_parameter_kw={
365 "url":"https://[1:2:3:4:5:6:7:8]:1234",
366 "domain": "www.example.org",
367 "enable_cache": "True",
369 "apache_custom_https":'
370 ServerName www.example.org
371 ServerAlias www.example.org
372 ServerAlias example.org
373 ServerAdmin geronimo@example.org
381 RewriteRule ^/(.*) %(cache_access)s/$1 [L,P]',
383 "apache_custom_http":'
384 ServerName www.example.org
385 ServerAlias www.example.org
386 ServerAlias example.org
387 ServerAdmin geronimo@example.org
395 # Remove "Secure" from cookies, as backend may be https
396 Header edit Set-Cookie "(?i)^(.+);secure$" "$1"
398 # Not using HTTPS? Ask that guy over there.
399 # Dummy redirection to https. Note: will work only if https listens
400 # on standard port (443).
401 RewriteRule ^/(.*) %(cache_access)s/$1 [L,P],
406 Advanced example (custom-personal)
407 ----------------------------------
409 Request slave frontend instance using custom apache configuration, willing to use cache and ssl certificates.
410 listening to a custom domain and redirecting to /erp5/ so that
411 https://[1:2:3:4:5:6:7:8]:1234/erp5/ will be redirected and accessible from
414 software_release=apache_frontend,
415 software_type="RootSoftwareInstance",
416 partition_reference='my frontend',
418 software_type="custom-personal",
419 partition_parameter_kw={
420 "url":"https://[1:2:3:4:5:6:7:8]:1234",
421 "enable_cache":"true",
424 "domain":"example.org",
426 "apache_custom_https":'
427 ServerName www.example.org
428 ServerAlias www.example.org
429 ServerAdmin example.org
432 SSLProtocol -ALL +SSLv3 +TLSv1
433 SSLHonorCipherOrder On
434 SSLCipherSuite RC4-SHA:HIGH:!ADH
435 # Use personal ssl certificates
436 SSLCertificateFile %(ssl_crt)s
437 SSLCertificateKeyFile %(ssl_key)s
438 SSLCACertificateFile %(ssl_ca_crt)s
439 SSLCertificateChainFile %(ssl_ca_crt)s
440 # Configure personal logs
441 ErrorLog "%(error_log)s"
443 LogFormat "%%h %%l %%{REMOTE_USER}i %%t \"%%r\" %%>s %%b \"%%{Referer}i\" \"%%{User-Agent}i\" %%D" combined
444 CustomLog "%(access_log)s" combined
450 # Redirect / to /index.html
451 RewriteRule ^/$ /index.html [R=302,L]
453 RewriteRule ^/(.*) %(cache_access)s/VirtualHostBase/https/www.example.org:443/erp5/VirtualHostRoot/$1 [L,P]',
455 "apache_custom_http":'
456 ServerName www.example.org
457 ServerAlias www.example.org
458 ServerAlias example.org
459 ServerAdmin geronimo@example.org
466 # Configure personal logs
467 ErrorLog "%(error_log)s"
469 LogFormat "%%h %%l %%{REMOTE_USER}i %%t \"%%r\" %%>s %%b \"%%{Referer}i\" \"%%{User-Agent}i\" %%D" combined
470 CustomLog "%(access_log)s" combined
471 # Remove "Secure" from cookies, as backend may be https
472 Header edit Set-Cookie "(?i)^(.+);secure$" "$1"
473 # Not using HTTPS? Ask that guy over there.
474 # Dummy redirection to https. Note: will work only if https listens
475 # on standard port (443).
476 RewriteRule ^/(.*)$ https://%%{SERVER_NAME}%%{REQUEST_URI}',
478 "ssl_key":"-----BEGIN RSA PRIVATE KEY-----
479 XXXXXXX..........XXXXXXXXXXXXXXX
480 -----END RSA PRIVATE KEY-----",
481 "ssl_crt":'-----BEGIN CERTIFICATE-----
482 XXXXXXXXXXX.............XXXXXXXXXXXXXXXXXXX
483 -----END CERTIFICATE-----',
484 "ssl_ca_crt":'-----BEGIN CERTIFICATE-----
485 XXXXXXXXX...........XXXXXXXXXXXXXXXXX
486 -----END CERTIFICATE-----',
487 "ssl_csr":'-----BEGIN CERTIFICATE REQUEST-----
488 XXXXXXXXXXXXXXX.............XXXXXXXXXXXXXXXXXX
489 -----END CERTIFICATE REQUEST-----',
496 It is not possible with slapos to listen to port <= 1024, because process are
499 Solution 1 (IPv4 only)
500 ----------------------
502 It is a good idea then to go on the node where the instance is
503 and set some iptables rules like (if using default ports)::
505 iptables -t nat -A PREROUTING -p tcp -d {public_ipv4} --dport 443 -j DNAT --to-destination {listening_ipv4}:4443
506 iptables -t nat -A PREROUTING -p tcp -d {public_ipv4} --dport 80 -j DNAT --to-destination {listening_ipv4}:8080
508 Where {public ip} is the public IP of your server, or at least the LAN IP to where your NAT will forward to.
509 {listening ip} is the private ipv4 (like 10.0.34.123) that the instance is using and sending as connection parameter.
511 Solution 2 (IPv6 only)
512 ----------------------
514 It is also possible to directly allow the service to listen on 80 and 443 ports using the following command:
516 setcap 'cap_net_bind_service=+ep' /opt/slapgrid/$APACHE_FRONTEND_SOFTWARE_RELEASE_MD5/parts/apache-2.2/bin/httpd
518 Then specify in the instance parameters "port" and "plain_http_port" to be 443 and 80, respectively.