Skip to content

Commit

Permalink
Python support
Browse files Browse the repository at this point in the history
  • Loading branch information
Szekeres Bálint committed Dec 2, 2018
1 parent 382aaf3 commit d4f3111
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
* Drupal security essentials
* Magento security essentials

### Python
* Python
* Python server
* Python backup server

### Routing
* `index`
* Fallback routing
Expand Down
20 changes: 20 additions & 0 deletions public/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
drupal: false,
magento: false,

python: false,
python_server: '/tmp/uwsgi.sock',
python_server_backup: '',

file_structure: 'modularized',
symlink: true,

Expand Down Expand Up @@ -547,6 +551,14 @@
return $scope.isPHP() && $scope.data.magento;
};

$scope.isPython = function() {
return $scope.data.python;
};

$scope.isPythonBackup = function() {
return $scope.isPython() && !!$scope.data.python_server_backup;
};

$scope.isCSP = function() {
return !!$scope.data.content_security_policy;
};
Expand Down Expand Up @@ -600,6 +612,14 @@
$scope.refreshHighlighting();
$scope.updateHash();

// toggle PHP <-> Python
if ($scope.data.php && !oldValue.php) {
$scope.data.python = false;
} else if ($scope.data.python && !oldValue.python) {
$scope.data.php = false;
}

// default index file
if (!$scope.data.php) {
$scope.defaultData.index = 'index.html';
} else {
Expand Down
53 changes: 51 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<link rel="icon" type="image/png" href="assets/img/favicon.png">
<title>nginxconfig.io</title>
<meta name="description" content="NGiИX configuration generator">
<meta name="keywords" content="nginx, config, configurator, /etc/nginx/nginx.conf, nginx performance, nginx tuning, nginx php, nginx, php fpm, wordpress, drupal, magento, Let's Encrypt, custom certificate, cdn, access_log, error_log, Laravel, Lumen, Symfony, Zend, CodeIgniter, Yii, CakePHP, Slim, Angular, React, Vue.js, Ember.js, reverse proxy, Node.js">
<meta name="keywords" content="nginx, config, configurator, /etc/nginx/nginx.conf, nginx performance, nginx tuning, nginx php, nginx, php fpm, wordpress, drupal, magento, python, django, Let's Encrypt, custom certificate, cdn, access_log, error_log, Laravel, Lumen, Symfony, Zend, CodeIgniter, Yii, CakePHP, Slim, Angular, React, Vue.js, Ember.js, reverse proxy, Node.js">
<meta property="og:title" content="nginxconfig.io">
<meta property="og:description" content="NGiИX configuration generator: HTTPS, HTTP2, CDN, PHP, HHVM, Frontend, Reverse proxy, Node.js, WordPress, Drupal, Magento, security headers, rate limiting, expiration by file types…">
<meta property="og:description" content="NGiИX configuration generator: HTTPS, HTTP2, CDN, PHP, HHVM, Frontend, Reverse proxy, Node.js, WordPress, Drupal, Magento, Python, Django, security headers, rate limiting, expiration by file types…">
<meta property="og:type" content="website">
<meta property="og:url" content="https://nginxconfig.io">
<meta property="og:image" content="https://nginxconfig.io/assets/img/share.png">
Expand Down Expand Up @@ -49,6 +49,9 @@
<li class="nav-item">
<a class="nav-link" ng-click="setTab('php')" ng-class="{ 'active': tab === 'php', 'changed': getChangesForTab('php') }">PHP<small ng-cloak>({{ getChangesForTab('php') }})</small></a>
</li>
<li class="nav-item">
<a class="nav-link" ng-click="setTab('python')" ng-class="{ 'active': tab === 'python', 'changed': getChangesForTab('python') }">Python<small ng-cloak>({{ getChangesForTab('python') }})</small></a>
</li>
<li class="nav-item">
<a class="nav-link" ng-click="setTab('routing')" ng-class="{ 'active': tab === 'routing', 'changed': getChangesForTab('routing') }">Routing<small ng-cloak>({{ getChangesForTab('routing') }})</small></a>
</li>
Expand Down Expand Up @@ -455,6 +458,42 @@
</div>
</div>
</div>
<div class="tab-pane tab-python" ng-class="{ 'active': tab === 'python' }">
<div class="form-group row">
<label class="col-sm-3 col-form-label col-form-label-sm">
Python
</label>
<div class="col-sm-9">
<div class="form-check" ng-class="{ 'input-changed': data.python !== defaultData.python }">
<input class="form-check-input" type="checkbox" id="python" ng-model="data.python">
<label class="form-check-label" for="python">enabled</label>
</div>
</div>
</div>
<div class="form-group row" ng-if="isPython()">
<label class="col-sm-3 col-form-label col-form-label-sm">
Python server
</label>
<div class="col-sm-9">
<input type="text"
class="form-control form-control-sm"
ng-model="data.python_server"
ng-class="{ 'input-changed': data.python_server !== defaultData.python_server }">
</div>
</div>
<div class="form-group row" ng-if="isPython()">
<label class="col-sm-3 col-form-label col-form-label-sm">
Python backup server
</label>
<div class="col-sm-9">
<input type="text"
class="form-control form-control-sm"
ng-model="data.python_server_backup"
ng-class="{ 'input-changed': data.python_server_backup !== defaultData.python_server_backup }"
placeholder="disabled">
</div>
</div>
</div>
<div class="tab-pane tab-routing" ng-class="{ 'active': tab === 'routing' }">
<fieldset class="form-group" ng-if="isPHP()">
<div class="row">
Expand Down Expand Up @@ -835,6 +874,16 @@
<pre><code class="nginx" ng-include="'templates/conf/nginxconfig.io/php_fastcgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-php_fastcgi" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="isPython() && isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/python_uwsgi.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-python_uwsgi" ngclipboard-success="clipboardSuccess('python_uwsgi.conf')">
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === 'python_uwsgi.conf'">Copied!</span>
<div class="code source" data-filename="nginxconfig.io/python_uwsgi.conf">
<pre><code class="nginx" ng-include="'templates/conf/nginxconfig.io/python_uwsgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-python_uwsgi" class="code highlighted"></div>
</section>
<section class="col-xl-6 grid-item file" ng-if="isProxy() && isModularized()" ng-cloak>
<strong>/etc/nginx/nginxconfig.io/proxy.conf</strong>
<button class="btn btn-light btn-clipboard" ngclipboard data-clipboard-target="#file-proxy" ngclipboard-success="clipboardSuccess('proxy.conf')">
Expand Down
7 changes: 7 additions & 0 deletions public/templates/conf/nginx.conf.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
server {{ data.php_server[0] === '/' ? 'unix:' : '' }}{{ data.php_server }};
server {{ data.php_server_backup[0] === '/' ? 'unix:' : '' }}{{ data.php_server_backup }} backup;
}
</span><!--
✔ Python backup --><span ng-if="isPythonBackup()">
upstream python {
server {{ data.python_server[0] === '/' ? 'unix:' : '' }}{{ data.python_server }};
server {{ data.python_server_backup[0] === '/' ? 'unix:' : '' }}{{ data.python_server_backup }} backup;
}
</span>
charset utf-8;
sendfile on;
Expand Down
9 changes: 9 additions & 0 deletions public/templates/conf/nginxconfig.io/python_uwsgi.conf.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# default uwsgi_params
include uwsgi_params;

# uwsgi settings
uwsgi_pass {{ !isPythonBackup() ? ((data.python_server[0] === '/' ? 'unix:' : '') + data.python_server) : 'python' }};
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
12 changes: 12 additions & 0 deletions public/templates/conf/sites-available/example.com.conf.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
try_files $uri $uri/ /index.php?$query_string;
}</span><!--
✔ Python --><span ng-if="isPython()">

# Python
location / {<!--
✔ modularized --><span ng-if="isModularized()">
include nginxconfig.io/python_uwsgi.conf;</span><!--
✔ unified --><span ng-if="isUnified()">
<!-- --> <ng-include ng-include-tabs="3" src="'templates/conf/nginxconfig.io/python_uwsgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></ng-include></span>
}</span><!--
✔ Reverse proxy --><span ng-if="isProxy()">

# reverse proxy
Expand Down

0 comments on commit d4f3111

Please sign in to comment.