apache as proxy

This commit is contained in:
usman@cyberpersons.com
2023-05-16 15:16:21 +05:00
parent bc723389b8
commit ade4e4fed1
5 changed files with 166 additions and 63 deletions

View File

@@ -63,8 +63,7 @@ app.controller('installExtensions', function ($scope, $http, $timeout) {
$scope.canNotPerform = true;
}
else {
} else {
$scope.canNotPerform = false;
$scope.errorMessage = response.data.error_message;
}
@@ -121,8 +120,7 @@ app.controller('installExtensions', function ($scope, $http, $timeout) {
$scope.canNotPerform = true;
}
else {
} else {
$scope.canNotPerform = false;
$scope.errorMessage = response.data.error_message;
}
@@ -145,7 +143,16 @@ app.controller('installExtensions', function ($scope, $http, $timeout) {
var phpSelection = $scope.phpSelection;
var queryString = window.location.search;
var searchParams = new URLSearchParams(queryString);
var param3Value = searchParams.get('apache');
if (param3Value === null) {
url = "/managephp/getExtensionsInformation";
console.log('Nothing found')
} else {
url = "/managephp/getExtensionsInformation?apache=apache";
}
var data = {
phpSelection: phpSelection,
@@ -175,8 +182,7 @@ app.controller('installExtensions', function ($scope, $http, $timeout) {
$scope.couldNotConnect = true;
}
else {
} else {
$scope.errorMessage = response.data.error_message;
$scope.canNotFetch = false;
$scope.couldNotConnect = true;
@@ -227,16 +233,14 @@ app.controller('installExtensions', function ($scope, $http, $timeout) {
$scope.goback = false;
$timeout.cancel();
}
else {
} else {
size = Number(response.data.size);
$scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000);
}
}
else {
} else {
}
@@ -312,7 +316,17 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
$('#file_uploads').bootstrapToggle('off');
$('#allow_url_include').bootstrapToggle('off');
var queryString = window.location.search;
var searchParams = new URLSearchParams(queryString);
var param3Value = searchParams.get('apache');
if (param3Value === null) {
url = "/managephp/getCurrentPHPConfig";
console.log('Nothing found')
} else {
url = "/managephp/getCurrentPHPConfig?apache=apache";
}
var data = {
phpSelection: phpSelection,
@@ -360,8 +374,7 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
$scope.phpDetailsBox = false;
}
else {
} else {
$scope.errorMessage = response.data.error_message;
$scope.canNotFetch = false;
@@ -387,7 +400,16 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
var phpSelection = $scope.phpSelection;
var queryString = window.location.search;
var searchParams = new URLSearchParams(queryString);
var param3Value = searchParams.get('apache');
if (param3Value === null) {
url = "/managephp/savePHPConfigBasic";
console.log('Nothing found')
} else {
url = "/managephp/savePHPConfigBasic?apache=apache";
}
var data = {
phpSelection: phpSelection,
@@ -420,8 +442,7 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
$scope.detailsSaved = false;
$scope.loadingPHP = true;
}
else {
} else {
$scope.errorMessage = response.data.error_message;
$scope.canNotFetch = false;
$scope.couldNotConnect = true;
@@ -451,7 +472,16 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
$scope.loadingPHP = false;
$scope.savebtnAdvance = true;
var queryString = window.location.search;
var searchParams = new URLSearchParams(queryString);
var param3Value = searchParams.get('apache');
if (param3Value === null) {
url = "/managephp/getCurrentAdvancedPHPConfig";
console.log('Nothing found')
} else {
url = "/managephp/getCurrentAdvancedPHPConfig?apache=apache";
}
var data = {
phpSelection: phpSelection,
@@ -481,8 +511,7 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
$scope.savebtnAdvance = false;
}
else {
} else {
$scope.canNotFetchAdvanced = false;
$scope.detailsSavedAdvanced = true;
$scope.loadingPHP = true;
@@ -511,7 +540,17 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
var phpSelection = $scope.phpSelection;
var queryString = window.location.search;
var searchParams = new URLSearchParams(queryString);
var param3Value = searchParams.get('apache');
if (param3Value === null) {
url = "/managephp/savePHPConfigAdvance";
console.log('Nothing found')
} else {
url = "/managephp/savePHPConfigAdvance?apache=apache";
}
var data = {
phpSelection: phpSelection,
@@ -536,8 +575,7 @@ app.controller('editPHPConfig', function ($scope, $http, $timeout) {
$scope.detailsSavedAdvanced = false;
$scope.loadingPHP = true;
}
else {
} else {
$scope.errorMessage = response.data.error_message;
$scope.canNotFetchAdvanced = false;
$scope.couldNotConnect = true;

View File

@@ -18,7 +18,7 @@
<div ng-controller="editPHPConfig" class="panel">
<div class="panel-body">
<h3 class="content-box-header">
{% trans "Edit PHP Configurations" %}
{% trans "Edit PHP Configurations" %} - {% if apache %}<a href="{% url 'editPHPConfigs' %}?apache=apache">Edit Apache Configurations</a>{% endif %}
</h3>
<div class="example-box-wrapper">
<ul class="nav nav-tabs">

View File

@@ -10,7 +10,7 @@
<div class="container">
<div id="page-title">
<h2>{% trans "Install PHP Extensions" %}</h2>
<h2>{% trans "Install PHP Extensions" %} - {% if apache %}<a href="{% url 'installExtensions' %}?apache=apache">Manage Apache Extensions</a>{% endif %}</h2>
<p>{% trans "Install/uninstall php extensions on this page." %}</p>
</div>
<div class="panel">

View File

@@ -3,6 +3,8 @@
import sys
import importlib
from ApachController.ApacheController import ApacheController
importlib.reload(sys)
from django.shortcuts import render, redirect
from loginSystem.views import loadLoginPage
@@ -1267,8 +1269,11 @@ def installExtensions(request):
except:
pass
# apache = ApacheController.checkIfApacheInstalled()
apache = 1
proc = httpProc(request, 'managePHP/installExtensions.html',
{'phps': PHPManager.findPHPVersions()}, 'admin')
{'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin')
return proc.render()
except KeyError:
@@ -1290,7 +1295,13 @@ def getExtensionsInformation(request):
data = json.loads(request.body)
phpVers = data['phpSelection']
if request.GET.get('apache', None) == None:
phpVers = f"lsphp{PHPManager.getPHPString(phpVers)}"
else:
phpVers = phpVers.replace(' ', '').lower()
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(f'PHP Version apache {phpVers}')
# php = PHP.objects.get(phpVers=phpVers)
@@ -1660,8 +1671,10 @@ def getRequestStatusApache(request):
def editPHPConfigs(request):
try:
#apache = ApacheController.checkIfApacheInstalled()
apache = 1
proc = httpProc(request, 'managePHP/editPHPConfig.html',
{'phps': PHPManager.findPHPVersions()}, 'admin')
{'phps': PHPManager.findPHPVersions(), 'apache': apache}, 'admin')
return proc.render()
except KeyError:
@@ -1682,8 +1695,11 @@ def getCurrentPHPConfig(request):
data = json.loads(request.body)
phpVers = data['phpSelection']
phpVers = "php" + PHPManager.getPHPString(phpVers)
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(f"apache value {request.GET.get('apache', None)}")
if request.GET.get('apache', None) == None:
phpVers = "php" + PHPManager.getPHPString(phpVers)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
else:
@@ -1692,6 +1708,10 @@ def getCurrentPHPConfig(request):
completeName = str(initial) + '.' + str(final)
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
else:
path = f'/etc/php/{phpVers.split(" ")[1]}/fpm/php.ini'
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(f'PHP Path {path}')
allow_url_fopen = "0"
display_errors = "0"
@@ -1802,10 +1822,19 @@ def savePHPConfigBasic(request):
phpVers = "php" + PHPManager.getPHPString(phpVers)
if request.GET.get('apache', None) == None:
apache = 0
else:
apache = 1
##
execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/phpUtilities.py"
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen + "' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" + allow_url_include + "' --memory_limit " + memory_limit + " --max_execution_time " + max_execution_time + " --upload_max_filesize " + upload_max_filesize + " --max_input_time " + max_input_time + " --post_max_size " + post_max_size
execPath = execPath + " savePHPConfigBasic --phpVers " + phpVers + " --allow_url_fopen '" + allow_url_fopen +\
"' --display_errors '" + display_errors + "' --file_uploads '" + file_uploads + "' --allow_url_include '" \
+ allow_url_include + "' --memory_limit " + memory_limit + " --max_execution_time " + \
max_execution_time + " --upload_max_filesize " + upload_max_filesize \
+ " --max_input_time " + max_input_time + " --post_max_size " + post_max_size + f" --apache {str(apache)}"
output = ProcessUtilities.outputExecutioner(execPath)
@@ -1843,8 +1872,12 @@ def getCurrentAdvancedPHPConfig(request):
data = json.loads(request.body)
phpVers = data['phpSelection']
phpVersS = phpVers
phpVers = "php" + PHPManager.getPHPString(phpVers)
if request.GET.get('apache', None) == None:
phpVers = "php" + PHPManager.getPHPString(phpVers)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
else:
@@ -1853,6 +1886,10 @@ def getCurrentAdvancedPHPConfig(request):
completeName = str(initial) + '.' + str(final)
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
else:
path = f'/etc/php/{phpVersS.split(" ")[1]}/fpm/php.ini'
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(f'PHP Path {path}')
command = "sudo cat " + path
configData = ProcessUtilities.outputExecutioner(command)
@@ -1884,9 +1921,11 @@ def savePHPConfigAdvance(request):
try:
data = json.loads(request.body)
phpVers = data['phpSelection']
phpVersS = phpVers
phpVers = "php" + PHPManager.getPHPString(phpVers)
if request.GET.get('apache', None) == None:
phpVers = "php" + PHPManager.getPHPString(phpVers)
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
else:
@@ -1895,6 +1934,10 @@ def savePHPConfigAdvance(request):
completeName = str(initial) + '.' + str(final)
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
else:
path = f'/etc/php/{phpVersS.split(" ")[1]}/fpm/php.ini'
if os.path.exists(ProcessUtilities.debugPath):
logging.writeToFile(f'PHP Path {path}')
tempPath = "/home/cyberpanel/" + str(randint(1000, 9999))

View File

@@ -100,7 +100,7 @@ class phpUtilities:
logging.CyberCPLogFileWriter.writeToFile(str(msg) + " [initiateRestore]")
@staticmethod
def savePHPConfigBasic(phpVers,allow_url_fopen,display_errors,file_uploads,allow_url_include,memory_limit,max_execution_time,upload_max_filesize,max_input_time,post_max_size):
def savePHPConfigBasic(phpVers,allow_url_fopen,display_errors,file_uploads,allow_url_include,memory_limit,max_execution_time,upload_max_filesize,max_input_time,post_max_size, apache):
try:
serverLevelPHPRestart = '/usr/local/lsws/admin/tmp/.lsphp_restart.txt'
@@ -108,6 +108,7 @@ class phpUtilities:
command = 'touch %s' % (serverLevelPHPRestart)
ProcessUtilities.executioner(command)
if int(apache) == 0:
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
path = "/usr/local/lsws/ls" + phpVers + "/etc/php.ini"
else:
@@ -116,6 +117,8 @@ class phpUtilities:
completeName = str(initial) + '.' + str(final)
path = "/usr/local/lsws/ls" + phpVers + "/etc/php/" + completeName + "/litespeed/php.ini"
else:
path = f'/etc/php/{phpVers[3]}.{phpVers[4]}/fpm/php.ini'
logging.CyberCPLogFileWriter.writeToFile(path)
@@ -154,6 +157,16 @@ class phpUtilities:
installUtilities.installUtilities.reStartLiteSpeed()
if int(apache) == 1:
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
phpService = f'php{phpVers}-php-fpm'
else:
phpService = f"php{phpVers[3]}.{phpVers[4]}-fpm"
command = f"systemctl restart {phpService}"
ProcessUtilities.normalExecutioner(command)
print("1,None")
except BaseException as msg:
@@ -178,6 +191,14 @@ class phpUtilities:
installUtilities.installUtilities.reStartLiteSpeed()
if ProcessUtilities.decideDistro() == ProcessUtilities.centos or ProcessUtilities.decideDistro() == ProcessUtilities.cent8:
phpService = f'php{phpVers}-php-fpm'
else:
phpService = f"php{phpVers.split('/')[3]}-fpm"
command = f"systemctl restart {phpService}"
ProcessUtilities.normalExecutioner(command)
print("1,None")
except BaseException as msg:
logging.CyberCPLogFileWriter.writeToFile(
@@ -227,6 +248,7 @@ def main():
parser.add_argument("--max_input_time", help="Process Hard Limit for PHP!")
parser.add_argument("--post_max_size", help="Process Hard Limit for PHP!")
parser.add_argument("--extension", help="Process Hard Limit for PHP!")
parser.add_argument("--apache", help="Editing apache!")
## Litespeed Tuning Arguments
@@ -237,7 +259,7 @@ def main():
if args.function == "savePHPConfigBasic":
phpUtilities.savePHPConfigBasic(args.phpVers, args.allow_url_fopen, args.display_errors, args.file_uploads, args.allow_url_include, args.memory_limit,
args.max_execution_time, args.upload_max_filesize, args.max_input_time, args.post_max_size)
args.max_execution_time, args.upload_max_filesize, args.max_input_time, args.post_max_size, args.apache)
elif args.function == "savePHPConfigAdvance":
phpUtilities.savePHPConfigAdvance(args.phpVers, args.tempPath)