feat: implement Nginx project configuration generation and service management IPC handlers
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
location /{{HOST}}/ {
|
||||||
|
alias "{{PATH}}/";
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
# Try the literal URI, then directory, then fallback to index.php
|
||||||
|
try_files $uri $uri/ /{{HOST}}/index.php?$query_string;
|
||||||
|
|
||||||
|
# PHP handling nested INSIDE the alias location to maintain context
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass 127.0.0.1:{{PHP_PORT}};
|
||||||
|
fastcgi_index index.php;
|
||||||
|
|
||||||
|
# Correctly split path to get the relative script path
|
||||||
|
fastcgi_split_path_info ^/{{HOST}}(.+\.php)(.*)$;
|
||||||
|
fastcgi_param SCRIPT_FILENAME "{{PATH}}$fastcgi_script_name";
|
||||||
|
fastcgi_param DOCUMENT_ROOT "{{PATH}}";
|
||||||
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
|
|
||||||
|
include "{{CONF_DIR}}/fastcgi_params";
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
48324
|
38592
|
||||||
|
|||||||
+21
-19
@@ -56,27 +56,29 @@ export function registerIpcHandlers(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const projects = await projectService.getProjects()
|
const projects = await projectService.getProjects()
|
||||||
const projectLocations = projects.map(p => {
|
const projectsConfDir = path.join(configService.getBasePath(), 'generated_configs', 'projects')
|
||||||
|
if (!fs.existsSync(projectsConfDir)) fs.mkdirSync(projectsConfDir, { recursive: true })
|
||||||
|
|
||||||
|
// Clean up old project configs
|
||||||
|
const existingFiles = fs.readdirSync(projectsConfDir)
|
||||||
|
for (const file of existingFiles) {
|
||||||
|
fs.unlinkSync(path.join(projectsConfDir, file))
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const p of projects) {
|
||||||
const phpPort = portMappingService.getPhpPort(p.phpVersion)
|
const phpPort = portMappingService.getPhpPort(p.phpVersion)
|
||||||
const normalizedPath = p.path.replace(/\\/g, '/')
|
const normalizedPath = p.path.replace(/\\/g, '/')
|
||||||
return `
|
await configService.generateConfig('nginx_project.conf.template', `projects/${p.host}.conf`, {
|
||||||
location /${p.host}/ {
|
HOST: p.host,
|
||||||
alias "${normalizedPath}/";
|
PATH: normalizedPath,
|
||||||
index index.php index.html;
|
PHP_PORT: phpPort.toString(),
|
||||||
try_files $uri $uri/ /${p.host}/index.php?$query_string;
|
CONF_DIR: confDir.replace(/\\/g, '/')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
# Sadece .php değil, URI'nin tamamını eşleştirip dosya adını $1 içine alıyoruz
|
const projectsInclusion = projects.length > 0
|
||||||
location ~ ^/${p.host}/(.*\.php)$ {
|
? `include "${projectsConfDir.replace(/\\/g, '/')}/*.conf";`
|
||||||
fastcgi_pass 127.0.0.1:${phpPort};
|
: ''
|
||||||
fastcgi_index index.php;
|
|
||||||
|
|
||||||
# Hatalı olan $request_filename yerine manuel path veriyoruz
|
|
||||||
fastcgi_param SCRIPT_FILENAME "${normalizedPath}/$1";
|
|
||||||
|
|
||||||
include "${confDir.replace(/\\/g, '/')}/fastcgi_params";
|
|
||||||
}
|
|
||||||
}`
|
|
||||||
}).join('\n')
|
|
||||||
|
|
||||||
const configPath = await configService.generateConfig('nginx.conf.template', 'nginx.conf', {
|
const configPath = await configService.generateConfig('nginx.conf.template', 'nginx.conf', {
|
||||||
PORT: settings.nginxPort,
|
PORT: settings.nginxPort,
|
||||||
@@ -85,7 +87,7 @@ export function registerIpcHandlers(): void {
|
|||||||
LOG_DIR: logDir.replace(/\\/g, '/'),
|
LOG_DIR: logDir.replace(/\\/g, '/'),
|
||||||
CONF_DIR: confDir.replace(/\\/g, '/'),
|
CONF_DIR: confDir.replace(/\\/g, '/'),
|
||||||
PHPMYADMIN_DIR: phpMyAdminService.getPath().replace(/\\/g, '/'),
|
PHPMYADMIN_DIR: phpMyAdminService.getPath().replace(/\\/g, '/'),
|
||||||
PROJECTS: projectLocations
|
PROJECTS: projectsInclusion
|
||||||
})
|
})
|
||||||
|
|
||||||
// Test config first with prefix
|
// Test config first with prefix
|
||||||
|
|||||||
Reference in New Issue
Block a user