Commit 7b4d9ecc authored by Thomas Lechauve's avatar Thomas Lechauve

html5as recipe created for nginx instance

parent 657544b3
[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"
##############################################################################
#
# 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]
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};
}
}
}
<!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
#!%(path_shell)s
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
exec %(path)s -c %(config_file)s
......@@ -7,7 +7,6 @@ extends =
parts =
nginx
html5as
[html5as]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment