Browse Source

Done Nginx configuration

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

23
ee/cli/plugins/stack.py

@ -7,6 +7,7 @@ from ee.core.aptget import EEAptGet
from ee.core.download import EEDownload
from ee.core.shellexec import EEShellExec
from ee.core.fileutils import EEFileUtils
from pynginxconfig import NginxConfig
import random
import string
@ -68,8 +69,30 @@ class EEStackController(CementBaseController):
@expose(hide=True)
def post_pref(self, apt_packages, packages):
if len(apt_packages):
print("In post")
print(apt_packages)
if "postfix" in apt_packages:
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 any('/usr/bin/wp' == x[1] for x in packages):

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