diff --git a/component/nginx/buildout.cfg b/component/nginx/buildout.cfg index d6437427ed1a98a9e837e50a8cf6b873663e5124..db1a0d40c9736a4d7e29679ad2ab73adb0a4902e 100644 --- a/component/nginx/buildout.cfg +++ b/component/nginx/buildout.cfg @@ -1,6 +1,7 @@ [buildout] extends = ../pcre/buildout.cfg + ../zlib/buildout.cfg parts = nginx @@ -8,5 +9,6 @@ parts = nginx recipe = hexagonit.recipe.cmmi url = http://nginx.org/download/nginx-1.0.14.tar.gz configure-options= - --with-ld-opt="-L ${pcre:location}/lib" - --with-cc-opt="-I ${pcre:location}/include" \ No newline at end of file + --with-ld-opt="-L ${pcre:location}/lib -Wl,-rpath=${pcre:location}/lib -Wl,-rpath=${zlib:location}/lib" + --with-cc-opt="-I ${pcre:location}/include" + diff --git a/slapos/recipe/html5as/__init__.py b/slapos/recipe/html5as/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..71484c5a8e0cf01a4d7b11704db8007a2ef21249 --- /dev/null +++ b/slapos/recipe/html5as/__init__.py @@ -0,0 +1,68 @@ +############################################################################## +# +# Copyright (c) 2011 Vifib SARL and Contributors. All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## +from slapos.recipe.librecipe import GenericBaseRecipe +import binascii +import os +import sys + +class Recipe(GenericBaseRecipe): + """ + nginx instance configuration. + """ + + def install(self): + config = dict( + nb_workers = self.options["nb_workers"] + path_pid = self.options["path_pid"] + path_log = self.options["path_log"] + path_access_log = self.options["path_access_log"] + root = self.options["root"] + ip = self.options["ip"] + port = self.options["port"] + path_shell = self.options["path_shell"] + config_file = self.options["config_file"] + path = self.options["path"] + ) + + # Configs + nginx_conf_file = self.createFile( + self.options['config_file'], + self.substituteTemplate(self.getTemplateFilename('nginx_conf.in', config)) + ) + + # Index default + nginx_index_file = self.createFile( + '/'.join([root,"index.html"), + self.substituteTemplate(self.getTemplateFilename('nginx_index.in', config)) + ) + + # Runners + runner_path = self.createExecutable( + self.options['path'], + self.substituteTemplate(self.getTemplateFilename('nginx_run.in'),config)) + + return [runner_path] diff --git a/slapos/recipe/html5as/templates/nginx_conf.in b/slapos/recipe/html5as/templates/nginx_conf.in new file mode 100644 index 0000000000000000000000000000000000000000..d7b5f25b62f651a7fad3213f4a10500b91a075bc --- /dev/null +++ b/slapos/recipe/html5as/templates/nginx_conf.in @@ -0,0 +1,51 @@ +worker_processes %{nb_workers}; + +user nobody nogroup; +pid %{path_pid}/nginx.pid; +error_log %{path_log}/nginx.error.log; + +events { + worker_connections 1024; + accept_mutex off; +} + +http { + include mime.types; + default_type application/octet-stream; + access_log %{path_access_log}/nginx.access.log combined; + sendfile on; + + server { + listen 80 default; + client_max_body_size 4G; + server_name _; + + keepalive_timeout 5; + + # path for static files + root %{root}; + + location / { + # checks for static file, if not found proxy to app + proxy_pass http://%{ip}:%{port}/; + proxy_redirect off; + + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location @proxy_to_app { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + + proxy_pass http://app_server; + } + + error_page 500 502 503 504 /500.html; + location = /500.html { + root %{root}; + } + } +} diff --git a/slapos/recipe/html5as/templates/nginx_index.in b/slapos/recipe/html5as/templates/nginx_index.in new file mode 100644 index 0000000000000000000000000000000000000000..58b08966c634503894225d1d85f97de9641bc7b7 --- /dev/null +++ b/slapos/recipe/html5as/templates/nginx_index.in @@ -0,0 +1,21 @@ +<!doctype html> +<html> + <head></head> + <body> + <center> + <h2>Nginx instance:</h2> + <ul> + <li>workers: %{nb_workers}</li> + <li>pid file : %{path_pid}</li> + <li>log file : %{path_log}</li> + <li>access log file : %{path_access_log}</li> + <li>root : %{root}</li> + <li>ip : %{ip}</li> + <li>port : %{port}</li> + <li>shell : %{path_shell}</li> + <li>config file : %{config_file}</li> + <li>server bin : %{path}</li> + </ul> + </center> + </body> +</html> \ No newline at end of file diff --git a/slapos/recipe/html5as/templates/nginx_run.in b/slapos/recipe/html5as/templates/nginx_run.in new file mode 100644 index 0000000000000000000000000000000000000000..be70144dd6f477000986608b82da7a93ce7d07f8 --- /dev/null +++ b/slapos/recipe/html5as/templates/nginx_run.in @@ -0,0 +1,5 @@ +#!%(path_shell)s +# BEWARE: This file is operated by slapgrid +# BEWARE: It will be overwritten automatically + +exec %(path)s -c %(config_file)s diff --git a/software/html5as/software.cfg b/software/html5as/software.cfg index 4ae15dd2029e144e26cdd5a478c2894ebf96d2bf..5a5c8644b0af6d5c03bcf523225ec95732531c05 100644 --- a/software/html5as/software.cfg +++ b/software/html5as/software.cfg @@ -7,7 +7,6 @@ extends = parts = nginx - html5as [html5as]