Browse Source

Done Nginx configuration

bugfixes
gau1991 10 years ago
parent
commit
b549c10524
  1. 4
      ee/cli/main.py
  2. 37
      ee/cli/plugins/stack.py
  3. 39
      ee/cli/templates/nginx-core.mustache

4
ee/cli/main.py

@ -24,8 +24,8 @@ class EEApp(foundation.CementApp):
label = 'ee' label = 'ee'
# Log writing to file # Log writing to file
#defaults = init_defaults('ee', 'log.logging') # defaults = init_defaults('ee', 'log.logging')
#defaults['log.logging']['file'] = '/tmp/my.log' # defaults['log.logging']['file'] = '/tmp/my.log'
config_defaults = defaults config_defaults = defaults

37
ee/cli/plugins/stack.py

@ -7,6 +7,7 @@ from ee.core.aptget import EEAptGet
from ee.core.download import EEDownload from ee.core.download import EEDownload
from ee.core.shellexec import EEShellExec from ee.core.shellexec import EEShellExec
from ee.core.fileutils import EEFileUtils from ee.core.fileutils import EEFileUtils
from pynginxconfig import NginxConfig
import random import random
import string import string
@ -68,9 +69,31 @@ class EEStackController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def post_pref(self, apt_packages, packages): def post_pref(self, apt_packages, packages):
if len(apt_packages): if len(apt_packages):
print("In post")
print(apt_packages)
if "postfix" in apt_packages: if "postfix" in apt_packages:
pass pass
pass if 'nginx-custom' in apt_packages:
# Nginx core configuration change using configparser
nc = NginxConfig()
print('in nginx')
nc.loadf('/etc/nginx/nginx.conf')
nc.set('worker_processes', 'auto')
nc.append(('worker_rlimit_nofile', '100000'), position=2)
nc.remove(('events', ''))
nc.append({'name': 'events', 'param': '', 'value':
[('worker_connections', '4096'),
('multi_accept', 'on')]}, position=4)
nc.set([('http',), 'keepalive_timeout'], '30')
nc.savef('/etc/nginx/nginx.conf')
# Custom Nginx configuration by EasyEngine
data = dict(version='EasyEngine 3.0.1')
ee_nginx = open('/etc/nginx/conf.d/ee-nginx.conf','w')
ee_nginx.write(self.app.render((data), 'nginx-core.mustache'))
ee_nginx.close()
pass
if len(packages): if len(packages):
if any('/usr/bin/wp' == x[1] for x in packages): if any('/usr/bin/wp' == x[1] for x in packages):
EEShellExec.cmd_exec("chmod +x /usr/bin/wp") EEShellExec.cmd_exec("chmod +x /usr/bin/wp")
@ -87,10 +110,10 @@ class EEStackController(CementBaseController):
EEVariables.ee_php + EEVariables.ee_mysql) EEVariables.ee_php + EEVariables.ee_mysql)
if self.app.pargs.admin: if self.app.pargs.admin:
pass pass
#apt_packages = apt_packages + EEVariables.ee_nginx # apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.mail: if self.app.pargs.mail:
pass pass
#apt_packages = apt_packages + EEVariables.ee_nginx # apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.nginx: if self.app.pargs.nginx:
apt_packages = apt_packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.php: if self.app.pargs.php:
@ -122,10 +145,10 @@ class EEStackController(CementBaseController):
EEVariables.ee_php + EEVariables.ee_mysql) EEVariables.ee_php + EEVariables.ee_mysql)
if self.app.pargs.admin: if self.app.pargs.admin:
pass pass
#apt_packages = apt_packages + EEVariables.ee_nginx # apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.mail: if self.app.pargs.mail:
pass pass
#apt_packages = apt_packages + EEVariables.ee_nginx # apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.nginx: if self.app.pargs.nginx:
apt_packages = apt_packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.php: if self.app.pargs.php:
@ -153,10 +176,10 @@ class EEStackController(CementBaseController):
+ EEVariables.ee_php + EEVariables.ee_mysql) + EEVariables.ee_php + EEVariables.ee_mysql)
if self.app.pargs.admin: if self.app.pargs.admin:
pass pass
#apt_packages = apt_packages + EEVariables.ee_nginx # apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.mail: if self.app.pargs.mail:
pass pass
#apt_packages = apt_packages + EEVariables.ee_nginx # apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.nginx: if self.app.pargs.nginx:
apt_packages = apt_packages + EEVariables.ee_nginx apt_packages = apt_packages + EEVariables.ee_nginx
if self.app.pargs.php: if self.app.pargs.php:

39
ee/cli/templates/nginx-core.mustache

@ -0,0 +1,39 @@
##
# EasyEngine Settings
##
server_tokens off;
reset_timedout_connection on;
add_header X-Powered-By "{{version}}";
add_header rt-Fastcgi-Cache $upstream_cache_status;
# Limit Request
limit_req_status 403;
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
# Proxy Settings
# set_real_ip_from proxy-server-ip;
# real_ip_header X-Forwarded-For;
fastcgi_read_timeout 300;
client_max_body_size 100m;
# SSL Settings
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5:!kEDH;
# Log format Settings
log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_status [$time_local] '
'$http_host "$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
# GZip settings
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
Loading…
Cancel
Save